Skip to content

Commit

Permalink
Merge pull request #85 from yupix/develop
Browse files Browse the repository at this point in the history
release v0.5.0
  • Loading branch information
yupix authored Jul 26, 2023
2 parents 7ae446e + d8e03f4 commit 7ccf797
Show file tree
Hide file tree
Showing 59 changed files with 2,365 additions and 522 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
contents: read

jobs:
build:
type-check:

runs-on: ubuntu-latest

Expand All @@ -30,5 +30,3 @@ jobs:
- name: Lint with flake8
run: |
flake8 mipac
- name: Lint with Ruff
run: ruff mipac
145 changes: 139 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,148 @@
# Change Log

All notable changes to this project will be documented in this file.
## [Unreleased]

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
### New Features ✨

## [Unreleased]
## [0.5.0] 2023-07-26

### Added
### New Features ✨

#### `Client``async with` 構文がサポートされました

一時的にセッションを作成したい場合などに `login` メソッドや `close_session` メソッドを使用するのは非常に手間であるため、一時的にセッションを作成したいといった場合におすすめします。

```py
async with Client('server url', 'token') as client:
api = client.api
async for emoji in api.admin.emoji.action.gets():
print(emoji)
```

#### 一意のIDを持つモデルで比較演算がサポートされました

サポートされた演算は `__eq__``__ne__` の2つです。一意のIDと判断しにくい物は現状サポートしていません。
一意のIDがあるにもかかわらず、サポートされていないモデルがある際はIssueを作成してください。

```py
note_one = await api.note.action.get('note one')
note_two = await api.note.action.get('note one')
note_three = await api.note.action.get('note two')
print(note_one == note_two, note_one != note_two)
print(note_one == note_three, note_one != note_three)
```

#### File モデルに `api` プロパティーが追加されました

今まではモデルに `api` プロパティーが無かったため、 `api` プロパティーからアクションにアクセスし、対象のメソッドに対してファイルIDなどといった引数を自分で渡す必要がありましたが、今後はモデルから直接実行できます。

```diff
-async for file in api.drive.file.action.get_files(get_all=True):
- await api.drive.file.action.remove(file.id)
+async for file in api.drive.file.action.get_files(get_all=True):
+ await file.api.action.remove()
```


#### `FileActions``save` メソッドが追加されました

指定したパス、またはBufferにファイルをダウンロードできるようになりました。
パスを指定する場合
```py
async for file in api.drive.file.action.get_files(get_all=True):
await file.api.action.save(f'./test/{file.name}')
```

Bufferを指定する場合:
```py
async for file in api.drive.file.action.get_files(get_all=True):
with open(f'./test/{file.name}', mode='mb') as f:
await file.api.action.save(f)
```

#### 以下のエンドポイントがサポートされました

- `/api/admin/emoji/set-license-bulk`
- `/api/antennas/create`
- `/api/antennas/delete`
- `/api/antennas/list`
- `/api/antennas/notes`
- `/api/antennas/show`
- `/api/antennas/update`
- `/api/clips/create`
- `/api/clips/delete`
- `/api/clips/list`
- `/api/clips/show`
- `/api/clips/update`
- `/api/notes/clips`
- `/api/clips/add-note`
- `/api/clips/remove-note`
- `/api/clips/notes`
- `/api/clips/my-favorites`
- `/api/users/clips`
- `/api/channels/create`
- `/api/channels/featured`
- `/api/channels/follow`
- `/api/channels/followed`
- `/api/channels/owned`
- `/api/channels/show`
- `/api/channels/unfollow`
- `/api/channels/update`
- `/api/channels/favorite`
- `/api/channels/unfavorite`
- `/api/channels/my-favorites`
- `/api/channels/search`

### Breaking changes 💔

#### 全取得の際の引数 `all``get_all` に変更されます。

影響を受けるのはキーワード引数を使用していた方です。位置引数を使用していた方は特に問題ありません。

```diff
-Client.api.admin.emoji.action.gets(all=True)
+Client.api.admin.emoji.action.gets(get_all=True)
```

- None
#### `NoteManager.get` メソッドが削除されました

何故あったのか分かりませんが、Managerの責務から逸脱しているためです

#### NoteActionsに関する変更

- `NoteActions.get` `NoteActions.fetch` メソッドにおいて `note_id` が optionalになっているのはおかしいため必須の引数に変更しました

### Fixed 🛠️

- 一部 `all` 引数が存在しないが、 built-inの `all` が存在することで動作していた箇所が修正されました
- `ClientNoteActions` において `note_id` が無かった場合の例外処理が無かった為追加

### Other notable changes 📜

- 新しい実績をサポートしました
- クリップがサポートされました
- ロールの作成時に `is_explorable` を使用できるようになりました。
- 最新のインスタンス等で無いと使用できない可能性があります
- update_metaのリクエスト時に `server_rules` パラメータが使用できるようになりました
- このパラメータは `13.11.3` 以降のバージョン(`13.11.3`は含みません)を使用している場合は必須であり、それ以前のバージョンを使用している場合は指定するとエラーが発生する可能性があります。
- `NoteActions.get_replies``ClientNoteActions.getriplies` に移動され、 `ClientNoteActions` でも使用可能になりました。(NoteActionsはClientNoteActionsを継承しているため今後とも使用できます)
- 全取得が以下のメソッドでサポートされました。それに伴い、一部のメソッドがジェネレーターになっています。
- `FederationActions.get_followers`
- `FederationActions.get_following`
- `FederationActions.get_users`
- `AdminAnnouncementActions.gets`
- `AdminRoleModelActions.get_users`
- `AdminAdvertisingActions.get_list`
- `AdminActions.get_moderation_logs`
- `NoteActions.get_replies`
- `NoteActions.gets`
- `FileActions.get_files`
- `ClientFolderActions.get_files`
- `DriveActions.get_folders`
- `Pagination` クラスが追加されました
- 基本的にユーザーが使うことは想定されていません
- [@omg-xtao](https://github.com/omg-xtao) can cancel setup_logging when init client.
- models/user にあった `FollowRequest` クラスが削除されました

## [0.4.3] 2023-04-25

Expand Down
31 changes: 8 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,24 @@ if __name__ == '__main__':
asyncio.run(main())
```

### Migration from v0.3.0 to v0.4.0

#### configの属性が変更されました

- `is_official` が削除されました

##### **重要** `use_version` が追加されました

Misskeyではv11,v12,v13とバージョンがあり、バージョンによっては使用できないAPIがあったりします。MiPACでは`use_version`を指定することで事前に使用できるかどうかを確認し、使用できない場合は`NotSupportVersion`という例外を返します。このようにご自分のインスタンスのバージョンを書いていただくだけで、よくわからないエラーを事前に防ぐことが出来ます。(issue等にエラーを報告場合は必ず適切に設定されているか確認してください)

v13はまだリリースされて日が浅く、全てのインスタンスがアップデートしたとは考えにくいため、現在のデフォルト値は`12`となっています。
### 注意事項

#### `Client` のオプションから `config`が削除されました
### Python3.12.0 final がリリースされ、3カ月経過後に最低バージョンを 3.12.0 に変更します

今後configを参照する際は `Client.config` を使用してください。
また、値を更新する場合はClient.config.from_dict()を用いることをお勧めします。
通常の変更方法との違いは以下の通りです。
これは主にMiPACの開発を行う上で、新規構文の使用などによってDXがより良くなり開発ペースが向上する為です。
また、使用者の皆様においてはPythonの高速化や新規構文の使用などが使用できるといった恩恵を得ることができます。

```python
Client.config.is_ayuskey = True
Client.config.use_version = 13
Client.config.from_dict(is_ayuskey=True, use_version=13)
```
現在Python3.12.0のリリースは以下のように記載されているため、早くて **2024年01月02日** に変更を実施する予定です。

上記のように複数の値を同時に更新する場合特に`from_dict`は有効な方法になります。
> `3.12.0 final: Monday, 2023-10-02`
### 注意事項
これについて意見がある場合はDiscussionを作成することができます。

### 一部サーバー(インスタンス)のバージョンによっては正常に動作しない可能性があります

MiPACの特徴として、v11,v12,v13のバージョンごとに生じる変更点をなるべく気にしなくてよいように作成していますが、現状の最新版であるv13でもv13の中で削除されたり、増えたりした物があります。結果的に追従しきれていない箇所があることがあります。そのため、そのような物を見つけた場合は、使用しているサーバーのバージョンと使用できないエンドポイント名をIssueに送信してください。

### モデルを基本的に自分でインスタンス化することは推奨しません
### モデルを自分でインスタンス化することは推奨されません

MiPACのモデルでは多くの場合、キーワード引数に `client`を受け取り、それを用いて`api` プロパティを生成します。しかし、サポート途中の機能なのではそこが省かれ、リリース後にモデルのインスタンス化に必要な引数として `client` が追加されることがあります。また、他にもモデルの更新のために引数が変更される可能性があります。そのため、引数の変更に関することをCHANGELOG等で通知することはありません。

Expand Down
7 changes: 4 additions & 3 deletions compiler/datas/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"/api/admin/queue/clear",
"/api/admin/queue/deliver-delayed",
"/api/admin/queue/inbox-delayed",
"/api/admin/queue/promote",
"/api/admin/queue/stats",
"/api/admin/relays/add",
"/api/admin/relays/list",
Expand Down Expand Up @@ -184,6 +185,7 @@
"/api/i/webhooks/delete",
"/api/meta",
"/api/emojis",
"/api/emoji",
"/api/mute/create",
"/api/mute/delete",
"/api/mute/list",
Expand Down Expand Up @@ -340,12 +342,11 @@
"/api/users/groups/transfer",
"/api/users/groups/update",
"/api/version",
"/api/admin/queue/promote",
"/api/channels/favorite",
"/api/channels/unfavorite",
"/api/channels/my-favorites",
"/api/channels/search",
"/api/emoji",
"/api/roles/notes",
"/api/users/update-memo"
"/api/users/update-memo",
"/api/admin/emoji/set-license-bulk"
]
Loading

0 comments on commit 7ccf797

Please sign in to comment.