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

feat!: use unified API spec, and go generator #39

Merged
merged 6 commits into from
Aug 30, 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
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/dist
/node_modules
/src/gen
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
es2021: true,
},
extends: ["standard-with-typescript", "prettier"],
plugins: ["unused-imports"],
overrides: [
{
env: {
Expand Down Expand Up @@ -33,5 +34,19 @@ module.exports = {
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-confusing-void-expression": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{
vars: "all",
varsIgnorePattern: "^_",
args: "after-used",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-empty-interface": "off",
eqeqeq: ["error", "smart"],
},
};
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
dist
src/gen
10 changes: 5 additions & 5 deletions .yarn/releases/yarn-1.22.22.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -79525,9 +79525,9 @@ declare var __webpack_require__: mixed;

function isHexCode(c) {
return (
(0x30 /* 0 */ <= c && c <= 0x39 /* 9 */) ||
(0x41 /* A */ <= c && c <= 0x46 /* F */) ||
(0x61 /* a */ <= c && c <= 0x66 /* f */)
(0x30 /* 0 */ <= c && c <= 0x39) /* 9 */ ||
(0x41 /* A */ <= c && c <= 0x46) /* F */ ||
(0x61 /* a */ <= c && c <= 0x66) /* f */
);
}

Expand Down Expand Up @@ -155112,8 +155112,8 @@ util.inherits(module.exports.ISO_8859_7, sbcs);
var bucket = this._getEncodeBucket(uCode);
var low = uCode & 0xff;
if (bucket[low] <= SEQ_START)
this.encodeTableSeq[SEQ_START - bucket[low]][DEF_CHAR] =
dbcsCode; // There's already a sequence, set a single-char subsequence of it.
this.encodeTableSeq[SEQ_START - bucket[low]][DEF_CHAR] = dbcsCode;
// There's already a sequence, set a single-char subsequence of it.
else if (bucket[low] == UNASSIGNED) bucket[low] = dbcsCode;
};

Expand Down
35 changes: 13 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,68 +55,59 @@

## [0.2.1](https://github.com/GetStream/stream-node/compare/v0.2.0...v0.2.1) (2024-05-15)


### Bug Fixes

* custom event signature ([#32](https://github.com/GetStream/stream-node/issues/32)) ([5e02b9b](https://github.com/GetStream/stream-node/commit/5e02b9bb333c5f7fa2a171e60a02ce997091c2ad))
- custom event signature ([#32](https://github.com/GetStream/stream-node/issues/32)) ([5e02b9b](https://github.com/GetStream/stream-node/commit/5e02b9bb333c5f7fa2a171e60a02ce997091c2ad))

## [0.2.0](https://github.com/GetStream/stream-node/compare/v0.1.13...v0.2.0) (2024-05-14)


### ⚠ BREAKING CHANGES

* upgrade to API v113.0.0 ([#28](https://github.com/GetStream/stream-node/issues/28))
- upgrade to API v113.0.0 ([#28](https://github.com/GetStream/stream-node/issues/28))

### Features

* delete recording and transcription methods ([#30](https://github.com/GetStream/stream-node/issues/30)) ([beb89ac](https://github.com/GetStream/stream-node/commit/beb89ac2f4470e0255b4a8c99cc5e1f5e9bb27d8))
* upgrade to API v113.0.0 ([#28](https://github.com/GetStream/stream-node/issues/28)) ([cc0d00d](https://github.com/GetStream/stream-node/commit/cc0d00ddfa18eaa01907310382cbce125655f586))
- delete recording and transcription methods ([#30](https://github.com/GetStream/stream-node/issues/30)) ([beb89ac](https://github.com/GetStream/stream-node/commit/beb89ac2f4470e0255b4a8c99cc5e1f5e9bb27d8))
- upgrade to API v113.0.0 ([#28](https://github.com/GetStream/stream-node/issues/28)) ([cc0d00d](https://github.com/GetStream/stream-node/commit/cc0d00ddfa18eaa01907310382cbce125655f586))

## [0.1.13](https://github.com/GetStream/stream-node/compare/v0.1.12...v0.1.13) (2024-03-26)


### Features

* listTranscriptions API ([#24](https://github.com/GetStream/stream-node/issues/24)) ([a170fd6](https://github.com/GetStream/stream-node/commit/a170fd6133b1fbeb01ba27987ffb8b50dd2c95fc))
- listTranscriptions API ([#24](https://github.com/GetStream/stream-node/issues/24)) ([a170fd6](https://github.com/GetStream/stream-node/commit/a170fd6133b1fbeb01ba27987ffb8b50dd2c95fc))

## [0.1.12](https://github.com/GetStream/stream-node/compare/v0.1.11...v0.1.12) (2024-03-08)


### Features

* update video to api v100.4.3 ([#22](https://github.com/GetStream/stream-node/issues/22)) ([2424b2d](https://github.com/GetStream/stream-node/commit/2424b2db10353dc46cd9c78c543666732228d5c7))

- update video to api v100.4.3 ([#22](https://github.com/GetStream/stream-node/issues/22)) ([2424b2d](https://github.com/GetStream/stream-node/commit/2424b2db10353dc46cd9c78c543666732228d5c7))

### Bug Fixes

* basePath not stored properly ([#20](https://github.com/GetStream/stream-node/issues/20)) ([3221ba0](https://github.com/GetStream/stream-node/commit/3221ba0ec1fe0bf002c6cf21794f23f1d6a818fd))
- basePath not stored properly ([#20](https://github.com/GetStream/stream-node/issues/20)) ([3221ba0](https://github.com/GetStream/stream-node/commit/3221ba0ec1fe0bf002c6cf21794f23f1d6a818fd))

## [0.1.11](https://github.com/GetStream/stream-node/compare/v0.1.10...v0.1.11) (2024-02-29)


### Bug Fixes

* add missing dependencies ([#18](https://github.com/GetStream/stream-node/issues/18)) ([5a1a75b](https://github.com/GetStream/stream-node/commit/5a1a75b8125be825788f3f520f29ac1d6024b2b7))
* persist [@ts-expect-error](https://github.com/ts-expect-error) comments in typing files ([#16](https://github.com/GetStream/stream-node/issues/16)) ([b1d3051](https://github.com/GetStream/stream-node/commit/b1d3051d8146031f7cb6b5f88bc07ee5a916d921))
- add missing dependencies ([#18](https://github.com/GetStream/stream-node/issues/18)) ([5a1a75b](https://github.com/GetStream/stream-node/commit/5a1a75b8125be825788f3f520f29ac1d6024b2b7))
- persist [@ts-expect-error](https://github.com/ts-expect-error) comments in typing files ([#16](https://github.com/GetStream/stream-node/issues/16)) ([b1d3051](https://github.com/GetStream/stream-node/commit/b1d3051d8146031f7cb6b5f88bc07ee5a916d921))

## [0.1.10](https://github.com/GetStream/stream-node/compare/v0.1.9...v0.1.10) (2024-02-12)


### Features

* add verifyWebhook method ([#12](https://github.com/GetStream/stream-node/issues/12)) ([e79f53c](https://github.com/GetStream/stream-node/commit/e79f53cdbed202428a99b5a0cf7df6baf200333c))
* update open api and implement external storage endpoints ([#15](https://github.com/GetStream/stream-node/issues/15)) ([fcd75e0](https://github.com/GetStream/stream-node/commit/fcd75e06d7a1c55021dc2ee47e12415e5b18a1b5))
- add verifyWebhook method ([#12](https://github.com/GetStream/stream-node/issues/12)) ([e79f53c](https://github.com/GetStream/stream-node/commit/e79f53cdbed202428a99b5a0cf7df6baf200333c))
- update open api and implement external storage endpoints ([#15](https://github.com/GetStream/stream-node/issues/15)) ([fcd75e0](https://github.com/GetStream/stream-node/commit/fcd75e06d7a1c55021dc2ee47e12415e5b18a1b5))

## [0.1.9](https://github.com/GetStream/stream-node/compare/v0.1.8...v0.1.9) (2023-12-01)


### Features

* update open api ([#10](https://github.com/GetStream/stream-node/issues/10)) ([05fbbf6](https://github.com/GetStream/stream-node/commit/05fbbf667039079b97f04ffef850bf624256fb09))
- update open api ([#10](https://github.com/GetStream/stream-node/issues/10)) ([05fbbf6](https://github.com/GetStream/stream-node/commit/05fbbf667039079b97f04ffef850bf624256fb09))

## [0.1.8](https://github.com/GetStream/stream-node/compare/v0.1.7...v0.1.8) (2023-12-01)


### Features

* Update open api ([4c461e7](https://github.com/GetStream/stream-node/commit/4c461e7e0d46a5c3c214d31934ac4ebc8b2a4ede))
- Update open api ([4c461e7](https://github.com/GetStream/stream-node/commit/4c461e7e0d46a5c3c214d31934ac4ebc8b2a4ede))
9 changes: 0 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ $ yarn generate:open-api
$ yarn generate:open-api:dev
```

If you want to update only chat or video you need to define the `PRODUCT` env variable like this:

```shell
$ PRODUCT=video yarn generate:open-api
$ PRODUCT=chat yarn generate:open-api:dev
```

The current chat open API contains some issues, to fix some of them apply the following commit manually after updating the chat open API: [87f8672f9c302138d2c19f07b9b5236e3ba98714](https://github.com/GetStream/stream-node/pull/42/commits/87f8672f9c302138d2c19f07b9b5236e3ba98714)

## Release (for Stream developers)

Releasing this package involves two GitHub Action steps:
Expand Down
25 changes: 10 additions & 15 deletions __tests__/block-lists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { beforeAll, describe, expect, it } from 'vitest';
import { v4 as uuidv4 } from 'uuid';
import { createTestClient } from './create-test-client';
import { StreamClient } from '../src/StreamClient';
import {
CreateBlockListRequest,
CreateBlockListRequestTypeEnum,
} from '../src/gen/chat';
import { CreateBlockListRequest } from '../src/gen/models';

describe('block lists CRUD API', () => {
let client: StreamClient;
Expand All @@ -16,48 +13,46 @@ describe('block lists CRUD API', () => {
blockList = {
name: 'streamnodetest-F1' + uuidv4(),
words: ['Ricciardo should retire'],
type: CreateBlockListRequestTypeEnum.WORD,
};
});

it('create', async () => {
const response = await client.chat.createBlockList(blockList);
const response = await client.createBlockList({
...blockList,
});

expect(response).toBeDefined();
});

it('list', async () => {
const listResponse = await client.chat.listBlockLists();
const listResponse = await client.listBlockLists();

expect(
listResponse.blocklists.find((b) => b.name === blockList.name),
).toBeDefined();

const getResponse = await client.chat.getBlockList({
name: blockList.name,
});
const getResponse = await client.getBlockList({ name: blockList.name });

expect(getResponse.blocklist?.name).toBe(blockList.name);
});

it('update', async () => {
const response = await client.chat.updateBlockList(blockList.name, {
const response = await client.updateBlockList({
name: blockList.name,
words: [...blockList.words, 'R1cciardo should retire'],
});

expect(response).toBeDefined();

const updatedBlockList = await client.chat.getBlockList({
const updatedBlockList = await client.getBlockList({
name: blockList.name,
});

expect(updatedBlockList.blocklist?.words.length).toBe(2);
});

it('delete', async () => {
const response = await client.chat.deleteBlockList({
name: blockList.name,
});
const response = await client.deleteBlockList({ name: blockList.name });
expect(response).toBeDefined();
});
});
21 changes: 10 additions & 11 deletions __tests__/call-members.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
import { createTestClient } from './create-test-client';
import { StreamCall } from '../src/StreamCall';
import { StreamClient } from '../src/StreamClient';
import { VideoOwnCapability } from '../src/gen/video';
import { OwnCapability } from '../src/gen/models';

describe('call members API', () => {
let client: StreamClient;
Expand All @@ -15,14 +15,12 @@ describe('call members API', () => {

call = client.video.call('default', callId);

await client.upsertUsers({
users: {
john: { name: 'John', id: 'john' },
jack: { name: 'Jack', id: 'jack' },
jane: { name: 'Jane', id: 'jane' },
sara: { name: 'Sara', id: 'sara' },
},
});
await client.upsertUsers([
{ name: 'John', id: 'john' },
{ name: 'Jack', id: 'jack' },
{ name: 'Jane', id: 'jane' },
{ name: 'Sara', id: 'sara' },
]);
});

it('create with members', async () => {
Expand Down Expand Up @@ -98,14 +96,14 @@ describe('call members API', () => {
it('grant and revoke permissions', async () => {
const revokeResponse = await call.updateUserPermissions({
user_id: 'sara',
revoke_permissions: [VideoOwnCapability.SEND_AUDIO],
revoke_permissions: [OwnCapability.SEND_AUDIO],
});

expect(revokeResponse).toBeDefined();

const grantResponse = await call.updateUserPermissions({
user_id: 'sara',
grant_permissions: [VideoOwnCapability.SEND_AUDIO],
grant_permissions: [OwnCapability.SEND_AUDIO],
});

expect(grantResponse).toBeDefined();
Expand All @@ -126,6 +124,7 @@ describe('call members API', () => {
expect(members.length).toBe(3);

const queryMembersReq = {
filter_conditions: {},
sort: [{ field: 'user_id', direction: 1 }],
limit: 2,
};
Expand Down
54 changes: 23 additions & 31 deletions __tests__/call-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { beforeAll, describe, expect, it } from 'vitest';
import { v4 as uuidv4 } from 'uuid';
import { createTestClient } from './create-test-client';
import { StreamClient } from '../src/StreamClient';
import {
VideoLayoutSettingsRequestNameEnum,
VideoOwnCapability,
VideoRecordSettingsRequestModeEnum,
VideoRecordSettingsRequestQualityEnum,
} from '../src/gen/video';
import { OwnCapability } from '../src/gen/models';

describe('call types CRUD API', () => {
let client: StreamClient;
Expand Down Expand Up @@ -44,9 +39,9 @@ describe('call types CRUD API', () => {
},
grants: {
admin: [
VideoOwnCapability.SEND_AUDIO,
VideoOwnCapability.SEND_VIDEO,
VideoOwnCapability.MUTE_USERS,
OwnCapability.SEND_AUDIO,
OwnCapability.SEND_VIDEO,
OwnCapability.MUTE_USERS,
],
},
});
Expand Down Expand Up @@ -86,45 +81,43 @@ describe('call types CRUD API', () => {
callTypeName
];
const userGrants = callType.grants.user.filter(
(c) => c !== VideoOwnCapability.JOIN_CALL,
(c) => c !== OwnCapability.JOIN_CALL,
);
const callMemberGrants = callType.grants.call_member;
if (!callMemberGrants.includes(VideoOwnCapability.JOIN_CALL)) {
callMemberGrants.push(VideoOwnCapability.JOIN_CALL);
if (!callMemberGrants.includes(OwnCapability.JOIN_CALL)) {
callMemberGrants.push(OwnCapability.JOIN_CALL);
}

await client.video.updateCallType(callTypeName, {
await client.video.updateCallType({
name: callTypeName,
grants: { user: userGrants, call_member: callMemberGrants },
});

callType = (await client.video.listCallTypes()).call_types[callTypeName];

expect(callType.grants.user.includes(VideoOwnCapability.JOIN_CALL)).toBe(
false,
expect(callType.grants.user.includes(OwnCapability.JOIN_CALL)).toBe(false);
expect(callType.grants.call_member.includes(OwnCapability.JOIN_CALL)).toBe(
true,
);
expect(
callType.grants.call_member.includes(VideoOwnCapability.JOIN_CALL),
).toBe(true);
});

it('update', async () => {
const updateResponse = await client.video.updateCallType(callTypeName, {
const updateResponse = await client.video.updateCallType({
name: callTypeName,
settings: {
audio: { mic_default_on: false, default_device: 'earpiece' },
recording: {
mode: VideoRecordSettingsRequestModeEnum.DISABLED,
mode: 'disabled',
// FIXME OL: these props shouldn't be required to be set when recording is disabled
audio_only: false,
quality: VideoRecordSettingsRequestQualityEnum._1080P,
quality: '1080p',
},
},
});

expect(updateResponse.settings.audio.mic_default_on).toBeFalsy();
expect(updateResponse.settings.audio.default_device).toBe('earpiece');
expect(updateResponse.settings.recording.mode).toBe(
VideoRecordSettingsRequestModeEnum.DISABLED,
);
expect(updateResponse.settings.recording.mode).toBe('disabled');
});

it('update layout options', async () => {
Expand All @@ -144,23 +137,22 @@ describe('call types CRUD API', () => {
'participant_label.background_color': 'transparent',
};

const response = await client.video.updateCallType(callTypeName, {
const response = await client.video.updateCallType({
name: callTypeName,
settings: {
recording: {
mode: VideoRecordSettingsRequestModeEnum.AVAILABLE,
mode: 'available',
audio_only: false,
quality: VideoRecordSettingsRequestQualityEnum._1080P,
quality: '1080p',
layout: {
name: VideoLayoutSettingsRequestNameEnum.SPOTLIGHT,
name: 'spotlight',
options: layoutOptions,
},
},
},
});

expect(response.settings.recording.layout.name).toBe(
VideoLayoutSettingsRequestNameEnum.SPOTLIGHT,
);
expect(response.settings.recording.layout.name).toBe('spotlight');
Object.keys(layoutOptions).forEach((key) => {
expect(response.settings.recording.layout.options![key]).toEqual(
(layoutOptions as any)[key],
Expand Down
Loading
Loading