Skip to main content

The script of the application runs in the RuntimeServer and provides team APIs to perform team-related operations.

caution

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

nametyperequireddescription
isAppClassBooleantruetrue: Access the table of applications / false Access the table of core
classNameStringtrueTable Name
paramsObjecttrueQuery 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;
};
caution

The returned ParseObject only implements the functionality of the Parse.Object part.

getAllData

Query all values according to conditions, similar to getData.

Api Parameters

nametyperequireddescription
isAppClassBooleantruetrue: Access the table of applications / false Access the table of core
classNameStringtrueTable Name
paramsObjecttrueQuery 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);
};
caution

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

nametyperequireddescription
classNameStringtrueTable Name
paramsObjecttrueQuery 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

nametyperequireddescription
methodStringtrueGET/POST/PUT/PATCH
urlStringtrueThe requested url
dataObjectfalseThe 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

nametyperequireddescription
isAppClassBooleantruetrue: Access the table of applications / false Access the table of core
classNameStringtrueTable 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());
});
};
caution

The returned ParseQuery only implements the functionality of the Parse.Query part.

getParseObject

Get the parse object according to the class name.

Api Parameters

nametyperequireddescription
isAppClassBooleantruetrue: Access the table of applications / false Access the table of core
classNameStringtrueTable 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]);
};
caution

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

nametyperequireddescription
isAppClassBooleantruetrue: Access the table of applications / false Access the table of core
classNameStringtrueTable 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);
};
caution

The returned ParseObjectSubclass only implements the functionality of the Parse.Object.SubClass part.

getParseFile

Get the Parse File object

Api Parameters

nametyperequireddescription
nameStringtrueFile name
dataParseFileDatatrueFile data
typeStringfalseFile 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 });
};
caution

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

nametyperequireddescription
listParseObject[]trueParse 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

nametyperequireddescription
dataParseObjecttrueParse 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

nametyperequireddescription
workspaceKeysString[]trueWorkspace 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

nametyperequireddescription
dataObjecttrueItem data

Method Signature

export declare const saveItemWithKey: (
data: Record<string, unknown>
) => Promise<any>;