Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-app-move-to-space-method
Browse files Browse the repository at this point in the history
  • Loading branch information
shabaraba committed Jul 10, 2024
2 parents d58f065 + e88b9f5 commit b1fbeb9
Show file tree
Hide file tree
Showing 17 changed files with 274 additions and 134 deletions.
10 changes: 10 additions & 0 deletions examples/rest-api-client-demo/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,4 +774,14 @@ export class App {
console.log(error);
}
}

public async getPlugins() {
try {
console.log(
await this.client.app.getPlugins({ app: APP_ID, lang: "en" }),
);
} catch (error) {
console.log(error);
}
}
}
9 changes: 9 additions & 0 deletions examples/rest-api-client-demo/src/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ export class Space {
}
}

public async addThread() {
const name = "The thread added via rest-api-client";
try {
console.log(await this.client.space.addThread({ space: SPACE_ID, name }));
} catch (error) {
console.log(error);
}
}

public async updateThread() {
const body = "<b>This is an updated thread body</b>";
const name = "Updated Thread Name";
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"fix:workspace": "pnpm -r --parallel run fix",
"fix:prettier": "pnpm lint:prettier --write",
"test:root": "jest",
"start": "pnpm build --watch",
"start": "pnpm -r --parallel run start",
"test": "pnpm test:root && pnpm -r --parallel run test",
"test:ci": "pnpm test:root && pnpm -r --stream run test:ci",
"test:e2e": "pnpm -r --parallel run test:e2e",
Expand Down Expand Up @@ -44,12 +44,12 @@
"@types/jest": "^29.5.12",
"@types/node": "^18.19.39",
"babel-jest": "^29.7.0",
"comment-json": "^4.2.3",
"comment-json": "^4.2.4",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"rimraf": "^5.0.9",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/create-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"bugs": "https://github.com/kintone/js-sdk/issues",
"dependencies": {
"chalk": "^4.1.2",
"glob": "^10.4.2",
"glob": "^10.4.5",
"inquirer": "^8.2.6",
"lodash": "^4.17.21",
"meow": "^9.0.0",
"node-rsa": "^1.1.1",
"normalize-path": "^3.0.0",
"os-locale": "^5.0.0",
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"rimraf": "^5.0.9",
"sort-package-json": "^1.57.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/customize-uploader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
"meow": "^9.0.0",
"mkdirp": "^3.0.1",
"os-locale": "^5.0.0",
"rimraf": "^5.0.7"
"rimraf": "^5.0.9"
}
}
6 changes: 3 additions & 3 deletions packages/plugin-packer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
"buffer": "^6.0.3",
"constants-browserify": "^1.0.0",
"crypto-browserify": "^3.12.0",
"cssnano": "^7.0.3",
"cssnano": "^7.0.4",
"execa": "^5.1.1",
"glob": "^10.4.2",
"glob": "^10.4.5",
"jest-environment-jsdom": "^29.7.0",
"normalize.css": "^8.0.1",
"path-browserify": "^1.0.1",
Expand All @@ -76,7 +76,7 @@
"process": "^0.11.10",
"redux-logger": "^3.0.6",
"redux-thunk": "^3.1.0",
"rimraf": "^5.0.7",
"rimraf": "^5.0.9",
"setimmediate": "^1.0.5",
"stream-browserify": "^3.0.0",
"util": "^0.12.5",
Expand Down
32 changes: 28 additions & 4 deletions packages/rest-api-client/docs/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [getAppActions](#getAppActions)
- [updateAppActions](#updateAppActions)
- [moveToSpace](#moveToSpace)
- [getPlugins](#getPlugins)

## Overview

Expand Down Expand Up @@ -1322,10 +1323,10 @@ Get the [Action](https://get.kintone.help/k/en/user/app_settings/appaction/set_a

#### Returns

| Name | Type | Description |
| -------- | :----: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| revision | String | The revision number of the App settings. |
| actions | Object | An object listing Action settings. An object listing Action settings. <br/>For each property of this object, see “Response Parameters” section of [the reference](https://kintone.dev/en/docs/kintone/rest-api/apps/get-action-settings/) |
| Name | Type | Description |
| -------- | :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| revision | String | The revision number of the App settings. |
| actions | Object | An object listing Action settings. <br/>For each property of this object, see “Response Parameters” section of [the reference](https://kintone.dev/en/docs/kintone/rest-api/apps/get-action-settings/) |

#### Reference

Expand Down Expand Up @@ -1373,3 +1374,26 @@ An empty object.
#### Reference

- https://kintone.dev/en/docs/kintone/rest-api/apps/move-app-to-space/

### getPlugins

Gets the list of Plug-ins added to an App.

#### Parameters

| Name | Type | Required | Description |
| ------- | :--------------: | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| app | Number or String | Yes | The App ID. |
| lang | String | | The localized language to retrieve the data in: <ul> <li>`en`: retrieves the localized English names</li> <li>`zh`: retrieves the localized Chinese names</li> <li>`ja`: retrieves the localized Japanese names</li> </ul>If ignored, the default names will be retrieved. |
| preview | Boolean | | A flag whether to get the app actions for pre-live environment |

#### Returns

| Name | Type | Description |
| -------- | :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| revision | String | The revision number of the App settings. |
| plugins | Object | An object listing Plug-ins. <br/>For each property of this object, see “Response Parameters” section of [the reference](https://kintone.dev/en/docs/kintone/rest-api/apps/get-app-plugins/) |

#### Reference

- https://kintone.dev/en/docs/kintone/rest-api/apps/get-app-plugins/
23 changes: 23 additions & 0 deletions packages/rest-api-client/docs/space.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [updateSpaceBody](#updateSpaceBody)
- [getSpaceMembers](#getSpaceMembers)
- [updateSpaceMembers](#updateSpaceMembers)
- [addThread](#addThread)
- [updateThread](#updateThread)
- [addThreadComment](#addThreadComment)
- [addGuests](#addGuests)
Expand Down Expand Up @@ -175,6 +176,28 @@ An empty object.

- https://kintone.dev/en/docs/kintone/rest-api/spaces/update-space-members/

### addThread

Adds a Thread of a Space.<br />
The Enable multiple threads option must be enabled in the space settings.

#### Parameters

| Name | Type | Required | Description |
| ----- | :--------------: | :------: | -------------------------------------------------------------------- |
| space | Number or String | Yes | The space ID. |
| name | String | Yes | The new name of the Thread.<br />Must be between 1 - 128 characters. |

#### Returns

| Name | Type | Description |
| ---- | :----: | ------------------------------------ |
| id | String | The thread ID of the created Thread. |

#### Reference

- https://kintone.dev/en/docs/kintone/rest-api/spaces/add-thread/

### updateThread

Updates a Thread of a Space.
Expand Down
8 changes: 4 additions & 4 deletions packages/rest-api-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
"@types/qs": "^6.9.15",
"rollup": "^4.18.0",
"rollup-plugin-ecma-version-validator": "^0.2.13",
"rollup-plugin-license": "^3.5.1",
"rollup-plugin-license": "^3.5.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-polyfill-node": "^0.13.0",
"webpack": "^5.92.1",
"webpack-cli": "^5.1.4",
"babel-loader": "^9.1.3",
"vite": "^5.3.2",
"rimraf": "^5.0.7",
"vite": "^5.3.3",
"rimraf": "^5.0.9",
"cross-env": "^7.0.3"
},
"dependencies": {
Expand All @@ -79,7 +79,7 @@
"form-data": "^4.0.0",
"js-base64": "^3.7.7",
"mime": "^3.0.0",
"qs": "^6.12.1"
"qs": "^6.12.3"
},
"exports": {
".": {
Expand Down
38 changes: 28 additions & 10 deletions packages/rest-api-client/src/client/AppClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
RecordID,
Revision,
Properties,
Lang,
AppLang,
Layout,
ViewForResponse,
ViewForParameter,
Expand Down Expand Up @@ -34,8 +34,10 @@ import type {
AppActionsForParameter,
AppActionsForResponse,
SpaceID,
PluginLocale,
} from "./types";
import { BaseClient } from "./BaseClient";
import type { AppPlugin } from "./types/app/plugin";
type RowLayoutForParameter = {
type: "ROW";
fields: Array<{ [key: string]: unknown }>;
Expand Down Expand Up @@ -69,7 +71,7 @@ type SpaceResponseParameters = {
export class AppClient extends BaseClient {
public getFormFields<T extends Properties>(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{ properties: T; revision: string }> {
const { preview, ...rest } = params;
Expand Down Expand Up @@ -142,7 +144,7 @@ export class AppClient extends BaseClient {

public getViews(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{
views: { [viewName: string]: ViewForResponse };
Expand Down Expand Up @@ -222,7 +224,7 @@ export class AppClient extends BaseClient {

public getAppSettings(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{
name: string;
Expand Down Expand Up @@ -293,7 +295,7 @@ export class AppClient extends BaseClient {

public getProcessManagement(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{
enable: boolean;
Expand Down Expand Up @@ -414,7 +416,7 @@ export class AppClient extends BaseClient {

public getRecordAcl(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{ rights: RecordRightForResponse[]; revision: string }> {
const { preview, ...rest } = params;
Expand Down Expand Up @@ -500,7 +502,7 @@ export class AppClient extends BaseClient {

public getPerRecordNotifications(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{
notifications: PerRecordNotificationForResponse[];
Expand Down Expand Up @@ -528,7 +530,7 @@ export class AppClient extends BaseClient {

public getReminderNotifications(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{
notifications: ReminderNotificationForResponse[];
Expand Down Expand Up @@ -558,7 +560,7 @@ export class AppClient extends BaseClient {

public getReports(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{
reports: { [reportName: string]: ReportForResponse };
Expand Down Expand Up @@ -589,7 +591,7 @@ export class AppClient extends BaseClient {

public getAppActions(params: {
app: AppID;
lang?: Lang;
lang?: AppLang;
preview?: boolean;
}): Promise<{
actions: AppActionsForResponse;
Expand Down Expand Up @@ -627,4 +629,20 @@ export class AppClient extends BaseClient {
});
return this.client.post(path, params);
}

public getPlugins(params: {
app: AppID;
lang?: PluginLocale;
preview?: boolean;
}): Promise<{
plugins: AppPlugin[];
revision: string;
}> {
const { preview, ...rest } = params;
const path = this.buildPathWithGuestSpaceId({
endpointName: "app/plugins",
preview,
});
return this.client.get(path, rest);
}
}
10 changes: 10 additions & 0 deletions packages/rest-api-client/src/client/SpaceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ export class SpaceClient extends BaseClient {
return this.client.put(path, params);
}

public addThread(params: {
space: SpaceID;
name: string;
}): Promise<{ id: string }> {
const path = this.buildPathWithGuestSpaceId({
endpointName: "space/thread",
});
return this.client.post(path, params);
}

public updateThread(params: {
id: ThreadID;
name?: string;
Expand Down
Loading

0 comments on commit b1fbeb9

Please sign in to comment.