Skip to content

Commit

Permalink
misskey-js -> cherrypick-js
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed Jun 12, 2023
1 parent 3e42aed commit 53a4e40
Show file tree
Hide file tree
Showing 175 changed files with 207 additions and 206 deletions.
10 changes: 5 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
'packages/sw':
- packages/sw/**/*

'packages/misskey-js':
- packages/misskey-js/**/*
'packages/cherrypick-js':
- packages/cherrypick-js/**/*

'packages/misskey-js:test':
- packages/misskey-js/test/**/*
- packages/misskey-js/test-d/**/*
'packages/cherrypick-js:test':
- packages/cherrypick-js/test/**/*
- packages/cherrypick-js/test-d/**/*
10 changes: 5 additions & 5 deletions .github/workflows/api-misskey-js.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: API report (misskey.js)
name: API report (cherrypick.js)

on: [push, pull_request]

Expand All @@ -23,14 +23,14 @@ jobs:
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm --filter misskey-js build
run: pnpm --filter cherrypick-js build

- name: Check files
run: ls packages/misskey-js/built
run: ls packages/cherrypick-js/built

- name: API report
run: pnpm --filter misskey-js api-prod
run: pnpm --filter cherrypick-js api-prod

- name: Show report
if: always()
run: cat packages/misskey-js/temp/misskey-js.api.md
run: cat packages/cherrypick-js/temp/cherrypick-js.api.md
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- backend
- frontend
- sw
- misskey-js
- cherrypick-js
steps:
- uses: actions/[email protected]
with:
Expand All @@ -62,7 +62,7 @@ jobs:
matrix:
workspace:
- backend
- misskey-js
- cherrypick-js
steps:
- uses: actions/[email protected]
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
- name: Build misskey-js
run: pnpm --filter misskey-js build
- name: Build cherrypick-js
run: pnpm --filter cherrypick-js build
- name: Build storybook
run: pnpm --filter frontend build-storybook
- name: Publish to Chromatic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Test (misskey.js)
name: Test (cherrypick.js)

on:
push:
Expand Down Expand Up @@ -38,15 +38,15 @@ jobs:
run: git diff --exit-code pnpm-lock.yaml

- name: Build
run: pnpm --filter misskey-js build
run: pnpm --filter cherrypick-js build

- name: Test
run: pnpm --filter misskey-js test
run: pnpm --filter cherrypick-js test
env:
CI: true

- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./packages/misskey-js/coverage/coverage-final.json
files: ./packages/cherrypick-js/coverage/coverage-final.json
1 change: 1 addition & 0 deletions CHANGELOG_CHERRYPICK.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

### Server
- mfm-js를 cherrypick-mfm-js로 변경
- misskey-js를 cherrypick-js로 변경

---

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ CherryPick uses [Storybook](https://storybook.js.org/) for UI development.
##### Setup

```bash
pnpm --filter misskey-js build
pnpm --filter cherrypick-js build
pnpm --filter frontend tsc -p .storybook && (node packages/frontend/.storybook/preload-locale.js & node packages/frontend/.storybook/preload-theme.js)
```

Expand All @@ -234,7 +234,7 @@ node packages/frontend/.storybook/generate.js && pnpm --filter frontend storyboo
##### Setup

```bash
pnpm --filter misskey-js build
pnpm --filter cherrypick-js build
```

##### Run
Expand Down Expand Up @@ -435,7 +435,7 @@ export const paramDef = {
```
### コネクションには`markRaw`せよ
**Vueのコンポーネントのdataオプションとして**misskey.jsのコネクションを設定するとき、必ず`markRaw`でラップしてください。インスタンスが不必要にリアクティブ化されることで、misskey.js内の処理で不具合が発生するとともに、パフォーマンス上の問題にも繋がる。なお、Composition APIを使う場合はこの限りではない(リアクティブ化はマニュアルなため)。
**Vueのコンポーネントのdataオプションとして**cherrypick.jsのコネクションを設定するとき、必ず`markRaw`でラップしてください。インスタンスが不必要にリアクティブ化されることで、misskey.js内の処理で不具合が発生するとともに、パフォーマンス上の問題にも繋がる。なお、Composition APIを使う場合はこの限りではない(リアクティブ化はマニュアルなため)。
### JSONのimportに気を付けよう
TypeScriptでjsonをimportすると、tscでコンパイルするときにそのjsonファイルも一緒にdistディレクトリに吐き出されてしまう。この挙動により、意図せずファイルの書き換えが発生することがあるので、jsonをimportするときは書き換えられても良いものかどうか確認すること。書き換えされて欲しくない場合は、importで読み込むのではなく、`fs.readFileSync`などの関数を使って読み込むようにすればよい。
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ COPY --link ["scripts", "./scripts"]
COPY --link ["packages/backend/package.json", "./packages/backend/"]
COPY --link ["packages/frontend/package.json", "./packages/frontend/"]
COPY --link ["packages/sw/package.json", "./packages/sw/"]
COPY --link ["packages/misskey-js/package.json", "./packages/misskey-js/"]
COPY --link ["packages/cherrypick-js/package.json", "./packages/cherrypick-js/"]

RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
pnpm i --frozen-lockfile --aggregate-output
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"meilisearch": "0.32.5",
"cherrypick-mfm-js": "0.23.3-cp-1.0.0",
"mime-types": "2.1.35",
"misskey-js": "workspace:*",
"cherrypick-js": "workspace:*",
"ms": "3.0.0-canary.1",
"nested-property": "4.0.0",
"node-fetch": "3.3.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/test/e2e/antennas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
uploadFile,
testPaginationConsistency,
} from '../utils.js';
import type * as misskey from 'misskey-js';
import type * as misskey from 'cherrypick-js';
import type { INestApplicationContext } from '@nestjs/common';

const compareBy = <T extends { id: string }>(selector: (s: T) => string = (s: T): string => s.id) => (a: T, b: T): number => {
Expand All @@ -28,7 +28,7 @@ describe('アンテナ', () => {
// エンティティとしてのアンテナを主眼においたテストを記述する
// (Antennaを返すエンドポイント、Antennaエンティティを書き換えるエンドポイント、Antennaからノートを取得するエンドポイントをテストする)

// BUG misskey-jsとjson-schemaが一致していない。
// BUG cherrypick-jsとjson-schemaが一致していない。
// - srcのenumにgroupが残っている
// - userGroupIdが残っている, isActiveがない
type Antenna = misskey.entities.Antenna | Packed<'Antenna'>;
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/test/e2e/clips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('クリップ', () => {
alice = await signup({ username: 'alice' });
bob = await signup({ username: 'bob' });

// FIXME: misskey-jsのNoteはoutdatedなので直接変換できない
// FIXME: cherrypick-jsのNoteはoutdatedなので直接変換できない
aliceNote = await post(alice, { text: 'test' }) as any;
aliceHomeNote = await post(alice, { text: 'home only', visibility: 'home' }) as any;
aliceFollowersNote = await post(alice, { text: 'followers only', visibility: 'followers' }) as any;
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/test/e2e/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
failedApiCall,
uploadFile,
} from '../utils.js';
import type * as misskey from 'misskey-js';
import type * as misskey from 'cherrypick-js';
import type { INestApplicationContext } from '@nestjs/common';

describe('ユーザー', () => {
Expand All @@ -31,7 +31,7 @@ describe('ユーザー', () => {
}, {});
};

// BUG misskey-jsとjson-schemaと実際に返ってくるデータが全部違う
// BUG cherrypick-jsとjson-schemaと実際に返ってくるデータが全部違う
type UserLite = misskey.entities.UserLite & {
badgeRoles: any[],
};
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { JSDOM } from 'jsdom';
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
import { entities } from '../src/postgres.js';
import { loadConfig } from '../src/config.js';
import type * as misskey from 'misskey-js';
import type * as misskey from 'cherrypick-js';

export { server as startServer } from '@/boot/common.js';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 18 additions & 18 deletions packages/misskey-js/README.md → packages/cherrypick-js/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
# misskey.js
**Strongly-typed official Misskey SDK for browsers/Node.js.**
# cherrypick.js
**Strongly-typed official CherryPick SDK for browsers/Node.js.**

[![Test](https://github.com/misskey-dev/misskey.js/actions/workflows/test.yml/badge.svg)](https://github.com/misskey-dev/misskey.js/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/misskey-dev/misskey.js/branch/develop/graph/badge.svg?token=PbrTtk3nVD)](https://codecov.io/gh/misskey-dev/misskey.js)

[![NPM](https://nodei.co/npm/misskey-js.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/misskey-js)

JavaScript(TypeScript)用の公式MisskeySDKです。ブラウザ/Node.js上で動作します。
JavaScript(TypeScript)用の公式CherryPickSDKです。ブラウザ/Node.js上で動作します。

以下が提供されています:
- ユーザー認証
- APIリクエスト
- ストリーミング
- ユーティリティ関数
- Misskeyの各種型定義
- CherryPickの各種型定義

対応するMisskeyのバージョンは12以上です
対応するCherryPickのバージョンは12以上です

## Install
```
npm i misskey-js
npm i cherrypick-js
```

# Usage
インポートは以下のようにまとめて行うと便利です。

``` ts
import * as Misskey from 'misskey-js';
import * as Misskey from 'cherrypick-js';
```

便宜上、以後のコード例は上記のように`* as Misskey`としてインポートしている前提のものになります。

ただし、このインポート方法だとTree-Shakingできなくなるので、コードサイズが重要なユースケースでは以下のような個別インポートをお勧めします。

``` ts
import { api as misskeyApi } from 'misskey-js';
import { api as misskeyApi } from 'cherrypick-js';
```

## Authenticate
Expand All @@ -45,7 +45,7 @@ APIを利用する際は、利用するサーバーの情報とアクセスト

``` ts
const cli = new Misskey.api.APIClient({
origin: 'https://misskey.test',
origin: 'https://cherrypick.test',
credential: 'TOKEN',
});

Expand All @@ -55,12 +55,12 @@ const meta = await cli.request('meta', { detail: true });
`request`の第一引数には呼び出すエンドポイント名、第二引数にはパラメータオブジェクトを渡します。レスポンスはPromiseとして返ります。

## Streaming
misskey.jsのストリーミングでは、二つのクラスが提供されます。
cherrypick.jsのストリーミングでは、二つのクラスが提供されます。
ひとつは、ストリーミングのコネクション自体を司る`Stream`クラスと、もうひとつはストリーミング上のチャンネルの概念を表す`Channel`クラスです。
ストリーミングを利用する際は、まず`Stream`クラスのインスタンスを初期化し、その後で`Stream`インスタンスのメソッドを利用して`Channel`クラスのインスタンスを取得する形になります。

``` ts
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const stream = new Misskey.Stream('https://cherrypick.test', { token: 'TOKEN' });
const mainChannel = stream.useChannel('main');
mainChannel.on('notification', notification => {
console.log('notification received', notification);
Expand All @@ -74,14 +74,14 @@ mainChannel.on('notification', notification => {

パラメータなし
``` ts
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const stream = new Misskey.Stream('https://cherrypick.test', { token: 'TOKEN' });

const mainChannel = stream.useChannel('main');
```

パラメータあり
``` ts
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const stream = new Misskey.Stream('https://cherrypick.test', { token: 'TOKEN' });

const messagingChannel = stream.useChannel('messaging', {
otherparty: 'xxxxxxxxxx',
Expand All @@ -92,7 +92,7 @@ const messagingChannel = stream.useChannel('messaging', {
`Channel`クラスの`dispose`メソッドを呼び出します。

``` ts
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const stream = new Misskey.Stream('https://cherrypick.test', { token: 'TOKEN' });

const mainChannel = stream.useChannel('main');

Expand All @@ -103,7 +103,7 @@ mainChannel.dispose();
`Channel`クラスはEventEmitterを継承しており、メッセージがサーバーから受信されると受け取ったイベント名でペイロードをemitします。

``` ts
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const stream = new Misskey.Stream('https://cherrypick.test', { token: 'TOKEN' });
const mainChannel = stream.useChannel('main');
mainChannel.on('notification', notification => {
console.log('notification received', notification);
Expand All @@ -114,7 +114,7 @@ mainChannel.on('notification', notification => {
`Channel`クラスの`send`メソッドを使用してメッセージをサーバーに送信することができます。

``` ts
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const stream = new Misskey.Stream('https://cherrypick.test', { token: 'TOKEN' });
const messagingChannel = stream.useChannel('messaging', {
otherparty: 'xxxxxxxxxx',
});
Expand All @@ -128,7 +128,7 @@ messagingChannel.send('read', {
`Stream`クラスの`_connected_`イベントが利用可能です。

``` ts
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const stream = new Misskey.Stream('https://cherrypick.test', { token: 'TOKEN' });
stream.on('_connected_', () => {
console.log('connected');
});
Expand All @@ -138,7 +138,7 @@ stream.on('_connected_', () => {
`Stream`クラスの`_disconnected_`イベントが利用可能です。

``` ts
const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const stream = new Misskey.Stream('https://cherrypick.test', { token: 'TOKEN' });
stream.on('_disconnected_', () => {
console.log('disconnected');
});
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## API Report File for "misskey-js"
## API Report File for "cherrypick-js"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "misskey-js",
"name": "cherrypick-js",
"version": "0.0.15",
"description": "Misskey SDK for JavaScript",
"description": "CherryPick SDK for JavaScript",
"main": "./built/index.js",
"types": "./built/index.d.ts",
"scripts": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/frontend/.storybook/fakes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { entities } from 'misskey-js'
import type { entities } from 'cherrypick-js'

export function abuseUserReport() {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"json5": "2.2.3",
"matter-js": "0.19.0",
"cherrypick-mfm-js": "0.23.3-cp-1.0.0",
"misskey-js": "workspace:*",
"cherrypick-js": "workspace:*",
"photoswipe": "5.3.7",
"prismjs": "1.29.0",
"punycode": "2.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/account.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineAsyncComponent, reactive, ref } from 'vue';
import * as misskey from 'misskey-js';
import * as misskey from 'cherrypick-js';
import { showSuspendedDialog } from './scripts/show-suspended-dialog';
import { i18n } from './i18n';
import { miLocalStorage } from './local-storage';
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as misskey from 'misskey-js';
import * as misskey from 'cherrypick-js';
import { Cache } from '@/scripts/cache';

export const clipsCache = new Cache<misskey.entities.Clip[]>(Infinity);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/MkAbuseReportWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<script setup lang="ts">
import { ref, shallowRef } from 'vue';
import * as Misskey from 'misskey-js';
import * as Misskey from 'cherrypick-js';
import MkWindow from '@/components/MkWindow.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import MkButton from '@/components/MkButton.vue';
Expand Down
Loading

0 comments on commit 53a4e40

Please sign in to comment.