The script of the application runs in the RuntimeServer and provides team APIs to perform team-related operations.
Can only be used by team-related app
Install
$ yarn add @giteeteam/apps-team-api
Apis list
getData
Provides the ability for applications to query Parse
data
Api Parameters
name | type | required | description |
---|---|---|---|
isAppClass | Boolean | true | true: Access the table of applications / false Access the table of core |
className | String | true | Table Name |
params | Object | true | Query object |
Method Signature
export declare const getData: (
isAppClass: boolean,
className: string,
params: Record<string, any>
) => Promise<ParseObject | undefined>;
Example
import { getData } from "@giteeteam/apps-team-api";
export const run = async () => {
const itemObj = await getData(false, "Item", { key: "klF8DIc0jr" });
return itemObj.id;
};
The returned ParseObject only implements the functionality of the Parse.Object part.
getAllData
Query all values according to conditions, similar to getData
.
Api Parameters
name | type | required | description |
---|---|---|---|
isAppClass | Boolean | true | true: Access the table of applications / false Access the table of core |
className | String | true | Table Name |
params | Object | true | Query object |
Method Signature
export declare const getAllData: (
isAppClass: boolean,
className: string,
params: Record<string, any>
) => Promise<ParseObject[]>;
Example
import { getAllData } from "@giteeteam/apps-team-api";
export const run = async () => {
const workflows = await getAllData(false, "WorkflowScheme", {});
const workflowIds = workflows.map((w) => w.id);
};
The returned ParseObject only implements the functionality of the Parse.Object part.
getAppsData
Query the data of the application center according to the conditional query.
Api Parameters
name | type | required | description |
---|---|---|---|
className | String | true | Table Name |
params | Object | true | Query object |
Method Signature
export declare const getAppsData: (
className: string,
params: Record<string, any>
) => Promise<any>;
Example
import { getAppsData } from "@giteeteam/apps-team-api";
export const run = async () => {
const appInfo = await getAppsData("Apps", { key: "test_manager" });
};
requestCoreApi
Provide the ability to directly call the core interface externally, and expose the GET/POST/PUT/PATCH methods
Api Parameters
name | type | required | description |
---|---|---|---|
method | String | true | GET/POST/PUT/PATCH |
url | String | true | The requested url |
data | Object | false | The requested data |
Example
import { requestCoreApi } from "@giteeteam/apps-team-api";
export const run = async () => {
const requestParams = {
form: 0,
size: 20,
};
return await requestCoreApi("POST", "/parse/api/search", requestParams);
};
getParseQuery
Get parse query based on class name
Api Parameters
name | type | required | description |
---|---|---|---|
isAppClass | Boolean | true | true: Access the table of applications / false Access the table of core |
className | String | true | Table Name |
Method Signature
export declare const getParseQuery: (
isAppClass: boolean,
className: string
) => ParseQuery;
Example
import { getParseQuery } from "@giteeteam/apps-team-api";
export const run = async ({ sessionToken }) => {
const query = getParseQuery(false, "Item");
const itemsInfo = await query
.containedIn("objectId", ids)
.include(["status", "workspace", "itemType"])
.findAll({ sessionToken })
.then((res) => {
return res.map((item) => item?.toJSON());
});
};
The returned ParseQuery only implements the functionality of the Parse.Query part.
getParseObject
Get the parse object according to the class name.
Api Parameters
name | type | required | description |
---|---|---|---|
isAppClass | Boolean | true | true: Access the table of applications / false Access the table of core |
className | String | true | Table Name |
Method Signature
export declare const getParseObject: (
isAppClass: boolean,
className: string
) => ParseObject;
Example
import { getParseObject, saveAllObject } from "@giteeteam/apps-team-api";
export const run = async () => {
const statusObject = getParseObject(false, "Status");
statusObject.set({
name,
type: types[idx],
description: `status-${name}`,
isDefault: false,
tenant,
createdBy,
});
await saveAllObject([statusObject]);
};
The returned ParseObject only implements the functionality of the Parse.Object part.
getParseModel
Get the Parse model object according to the class name.
Api Parameters
name | type | required | description |
---|---|---|---|
isAppClass | Boolean | true | true: Access the table of applications / false Access the table of core |
className | String | true | Table Name |
Method Signature
export declare const getParseModel: (
isAppClass: boolean,
className: string
) => typeof ParseObjectSubclassType;
Example
import { getParseModel } from "@giteeteam/apps-team-api";
export const run = async () => {
const itemParseObj = getParseModel(false, "Item");
itemParseObj.createWithoutData(id);
};
The returned ParseObjectSubclass only implements the functionality of the Parse.Object.SubClass part.
getParseFile
Get the Parse File object
Api Parameters
name | type | required | description |
---|---|---|---|
name | String | true | File name |
data | ParseFileData | true | File data |
type | String | false | File type |
Method Signature
export type ParseFileData =
| number[]
| { base64: string }
| { size: number; type: string }
| { uri: string };
export declare const getParseFile: (
name: string,
data: ParseFileData,
type?: string
) => ParseFile;
Example
import { getParseFile } from "@giteeteam/apps-team-api";
export const run = async () => {
const ParseFile = getParseFile(fileName, { base64: "" });
const { _url } = await ParseFile.save({ sessionToken });
};
The returned ParseFile only implements the functionality of the Parse.File part.
saveAllObject
Save multiple parse objects, since the objects have been processed by appKey, there is no need to distinguish when saving.
Api Parameters
name | type | required | description |
---|---|---|---|
list | ParseObject[] | true | Parse object list |
Method Signature
export declare const saveAllObject: (
list: (ParseObject | ParseObjectSubclassType)[]
) => Promise<ParseObject[]>;
For usage, please refer to getParseObject
deleteParseObject
Delete a data
Api Parameters
name | type | required | description |
---|---|---|---|
data | ParseObject | true | Parse object |
Method Signature
export declare const deleteParseObject: (data: ParseObject) => Promise<void>;
Example
import { getData, deleteParseObject } from "@giteeteam/apps-team-api";
export const run = async () => {
const _workflowSchemeConfig = await getData(false, "WorkflowSchemeConfig", {
itemType: manHourItemType,
workflow: manHourWorkflow,
workflowScheme: ws,
tenant,
});
if (_workflowSchemeConfig) {
await deleteParseObject(_workflowSchemeConfig);
}
};
getWorkspaceByKeys
Get space list according to space keys
Api Parameters
name | type | required | description |
---|---|---|---|
workspaceKeys | String[] | true | Workspace key list |
Method Signature
export declare const getWorkspaceByKeys: (
workspaceKeys: string[]
) => Promise<ParseObject[]>;
Example
import { getWorkspaceByKeys } from "@giteeteam/apps-team-api";
export const run = async () => {
const workspaces = await getWorkspaceByKeys(["www"]);
const ids = workspaces.map((w) => w.id);
};
saveItemWithKey
Generate an item with a key field by calling the create item interface provided by core
Api Parameters
name | type | required | description |
---|---|---|---|
data | Object | true | Item data |
Method Signature
export declare const saveItemWithKey: (
data: Record<string, unknown>
) => Promise<any>;