@kissflow/lowcode-client-sdk 1.0.50 → 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +159 -1
- package/dist/kf.lowcodeworkersdk.es.js +1887 -0
- package/dist/kfsdk.es.js +206 -28
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +159 -1
- package/dist/lowcode.types.d.ts +144 -0
- package/dist/nocode.d.ts +159 -1
- package/dist/nocode.types.d.ts +72 -0
- package/dist/snippets.json +21 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -65,7 +65,14 @@ declare module "core/constants" {
|
|
|
65
65
|
CUSTOM_AGENT_GET_EXECUTION: string;
|
|
66
66
|
CUSTOM_AGENT_WATCH_EXECUTION: string;
|
|
67
67
|
CUSTOM_AGENT_STOP_WATCH: string;
|
|
68
|
+
CUSTOM_FUNCTION_RUN: string;
|
|
69
|
+
CUSTOM_FUNCTION_GET_RUN: string;
|
|
70
|
+
CUSTOM_FUNCTION_ON_RUN_COMPLETE: string;
|
|
71
|
+
CUSTOM_FUNCTION_STOP_WATCH: string;
|
|
68
72
|
DECISION_TABLE_EXECUTE: string;
|
|
73
|
+
REPORT_GET_DATA: string;
|
|
74
|
+
REPORT_GET_COUNT: string;
|
|
75
|
+
REPORT_GET_FIELDS: string;
|
|
69
76
|
DATAFORM_IMPORT_CSV: string;
|
|
70
77
|
DATAFORM_OPEN_FORM: string;
|
|
71
78
|
DATAFORM_GET_FIELDS: string;
|
|
@@ -123,6 +130,7 @@ declare module "core/constants" {
|
|
|
123
130
|
CC_ON_PARAMS_CHANGE: string;
|
|
124
131
|
CC_ON_ROUTE_CHANGE: string;
|
|
125
132
|
CUSTOM_AGENT_EXECUTION_COMPLETE: string;
|
|
133
|
+
CUSTOM_FUNCTION_RUN_COMPLETE: string;
|
|
126
134
|
};
|
|
127
135
|
export const DEFAULTS: {
|
|
128
136
|
POPUP_ID: string;
|
|
@@ -345,6 +353,34 @@ declare module "types/external" {
|
|
|
345
353
|
payload?: PayloadOptions;
|
|
346
354
|
};
|
|
347
355
|
export type DataformQueryResponse = QueryResponse;
|
|
356
|
+
export type ReportFlowType = "Form" | "Process" | "Case";
|
|
357
|
+
export type ReportPayload = {
|
|
358
|
+
FilterParam?: Record<string, string | string[] | object>;
|
|
359
|
+
};
|
|
360
|
+
export type ReportQueryOptions = {
|
|
361
|
+
pageNumber?: number;
|
|
362
|
+
pageSize?: number;
|
|
363
|
+
payload?: ReportPayload;
|
|
364
|
+
};
|
|
365
|
+
export type ReportCountOptions = {
|
|
366
|
+
payload?: ReportPayload;
|
|
367
|
+
};
|
|
368
|
+
export type ReportField = {
|
|
369
|
+
Id: string;
|
|
370
|
+
Name: string;
|
|
371
|
+
[key: string]: any;
|
|
372
|
+
};
|
|
373
|
+
export type ReportDataResponse = {
|
|
374
|
+
Data: any[];
|
|
375
|
+
Columns?: any[];
|
|
376
|
+
Rows?: any[];
|
|
377
|
+
Values?: any[];
|
|
378
|
+
FieldMapping?: any[];
|
|
379
|
+
Formatting?: any[];
|
|
380
|
+
Id?: string;
|
|
381
|
+
Name?: string;
|
|
382
|
+
[key: string]: any;
|
|
383
|
+
};
|
|
348
384
|
export type DataformCreateItemOptions = {
|
|
349
385
|
data?: object;
|
|
350
386
|
viewId?: string;
|
|
@@ -411,6 +447,37 @@ declare module "types/external" {
|
|
|
411
447
|
tableId?: string;
|
|
412
448
|
tableRowId?: string;
|
|
413
449
|
};
|
|
450
|
+
/** The terminal states a Custom Function run ends in, plus the two it passes through. */
|
|
451
|
+
export type RunStatus = "Queued" | "Running" | "Success" | "Failed" | "TimedOut";
|
|
452
|
+
/**
|
|
453
|
+
* What a Custom Function run looks like from the SDK.
|
|
454
|
+
*
|
|
455
|
+
* An Interactive function resolves with the terminal envelope directly. A
|
|
456
|
+
* Background function resolves with `Queued` and only `RunId`; fetch the rest
|
|
457
|
+
* with `getFunctionRun`, or wait for it with `onFunctionRunComplete`.
|
|
458
|
+
*/
|
|
459
|
+
export type RunEnvelope = {
|
|
460
|
+
RunId: string;
|
|
461
|
+
Status: RunStatus;
|
|
462
|
+
/** Whatever the function returned. Only constrained when its output contract names properties. */
|
|
463
|
+
Result?: unknown;
|
|
464
|
+
Error?: {
|
|
465
|
+
Code?: string;
|
|
466
|
+
Message: string;
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* How a Custom Function call fails: `error` is the message text and `errorCode` either the platform
|
|
471
|
+
* code (`KISSFLOW_ERROR_…`) or a `FUNCTION_…` code, including `FUNCTION_HOST_TIMEOUT`,
|
|
472
|
+
* `FUNCTION_REQUEST_NOT_SENT`, `FUNCTION_RUN_OUTCOME_UNKNOWN` (a run may have started),
|
|
473
|
+
* `FUNCTION_RUN_NOT_SENT` (no run started), `FUNCTION_HOST_UNSUPPORTED`, `FUNCTION_WATCH_INVALID_EVENT`
|
|
474
|
+
* and `FUNCTION_OBSERVATION_STOPPED`. The list may grow; fall back to `error` for an unknown code.
|
|
475
|
+
*/
|
|
476
|
+
export type RunWatchError = {
|
|
477
|
+
isError: true;
|
|
478
|
+
error?: string;
|
|
479
|
+
errorCode?: string;
|
|
480
|
+
};
|
|
414
481
|
export type AgentInputDataType = "Text" | "Number" | "Boolean" | "Attachment";
|
|
415
482
|
export type AgentOutputDataType = "string" | "number" | "boolean";
|
|
416
483
|
export type AgentInputField = {
|
|
@@ -937,6 +1004,33 @@ declare module "app/agent" {
|
|
|
937
1004
|
onExecutionComplete(executionId: string, onComplete: (execution: AgentExecution) => void, onWatchError?: (error: AgentError) => void): () => void;
|
|
938
1005
|
}
|
|
939
1006
|
}
|
|
1007
|
+
declare module "app/report" {
|
|
1008
|
+
import { BaseSDK } from "core/index";
|
|
1009
|
+
import { ReportFlowType, ReportQueryOptions, ReportCountOptions, ReportField, ReportDataResponse } from "types/external";
|
|
1010
|
+
/**
|
|
1011
|
+
* A flow report of the current app. The handle sends no request until you call one of its methods.
|
|
1012
|
+
*
|
|
1013
|
+
* @example
|
|
1014
|
+
* const report = kf.app.getReport("Process", "Leave_Request_A00", "Requests_by_status_x1Yz");
|
|
1015
|
+
* const { Data } = await report.getData();
|
|
1016
|
+
*/
|
|
1017
|
+
export class Report extends BaseSDK {
|
|
1018
|
+
private _flowType;
|
|
1019
|
+
private _flowId;
|
|
1020
|
+
private _id;
|
|
1021
|
+
constructor(flowType: ReportFlowType, flowId: string, reportId: string);
|
|
1022
|
+
/**
|
|
1023
|
+
* The report's calculated rows: groups and their values for a chart, the aggregate for a card.
|
|
1024
|
+
* @param options - pageNumber (a whole number from 1, default 1), pageSize (a whole number from 1 to 100, default 50), payload (sent as the request body; filter at read time with the report's parameters, { FilterParam: { "$name": "text" } }; a falsy value is skipped, so send 0 as "0")
|
|
1025
|
+
*/
|
|
1026
|
+
getData(options?: ReportQueryOptions): Promise<ReportDataResponse>;
|
|
1027
|
+
/** The number of rows a tabular report would return. Chart and card reports have no row count; use getData(). */
|
|
1028
|
+
getCount(options?: ReportCountOptions): Promise<number>;
|
|
1029
|
+
/** The fields of a tabular report. Empty for chart and card reports; use getData(). */
|
|
1030
|
+
getFields(): Promise<ReportField[]>;
|
|
1031
|
+
private _send;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
940
1034
|
declare module "form/index" {
|
|
941
1035
|
import { BaseSDK } from "core/index";
|
|
942
1036
|
export class Form extends BaseSDK {
|
|
@@ -1454,19 +1548,74 @@ declare module "app/index" {
|
|
|
1454
1548
|
import { BaseSDK } from "core/index";
|
|
1455
1549
|
import { Page } from "app/page";
|
|
1456
1550
|
import { AppContext } from "types/internal";
|
|
1457
|
-
import { rolesObject } from "types/external";
|
|
1551
|
+
import { rolesObject, ReportFlowType, RunEnvelope, RunWatchError } from "types/external";
|
|
1458
1552
|
import { DecisionTable } from "app/decisiontable";
|
|
1459
1553
|
import { Agent } from "app/agent";
|
|
1554
|
+
import { Report } from "app/report";
|
|
1460
1555
|
import { Dataform } from "dataform/index";
|
|
1461
1556
|
import { Board } from "board/index";
|
|
1462
1557
|
import { Process } from "process/index";
|
|
1463
1558
|
export class Application extends BaseSDK {
|
|
1464
1559
|
page: Page;
|
|
1465
1560
|
_id: string;
|
|
1561
|
+
private activeWatches;
|
|
1466
1562
|
constructor(props: AppContext, isCustomComponent?: boolean);
|
|
1467
1563
|
getVariable(key: string): any;
|
|
1468
1564
|
setVariable(key: string | object, value?: any): any;
|
|
1469
1565
|
openPage(pageId: string, pageParams?: object): any;
|
|
1566
|
+
/**
|
|
1567
|
+
* Run a published Custom Function by name.
|
|
1568
|
+
*
|
|
1569
|
+
* An Interactive function resolves with its terminal envelope. A Background
|
|
1570
|
+
* function resolves as soon as it is queued, with `Status: "Queued"` and a
|
|
1571
|
+
* `RunId`; use {@link getFunctionRun} or {@link onFunctionRunComplete} for its result.
|
|
1572
|
+
*
|
|
1573
|
+
* A refused run rejects with the platform's SDK error shape: the message
|
|
1574
|
+
* text is in `error` and the code (`KISSFLOW_ERROR_…`) in `errorCode`.
|
|
1575
|
+
* A host that does not answer within 45 s rejects with
|
|
1576
|
+
* `FUNCTION_RUN_OUTCOME_UNKNOWN`: the run may still have started, so tell
|
|
1577
|
+
* the user instead of starting another.
|
|
1578
|
+
*
|
|
1579
|
+
* Custom Functions are application-scoped: this is reachable from page,
|
|
1580
|
+
* component and flow event scripts that run inside an application, where
|
|
1581
|
+
* `kf.app` exists. There is no `kf.app` outside one.
|
|
1582
|
+
*
|
|
1583
|
+
* @example
|
|
1584
|
+
* const run = await kf.app.runFunction("review_expense_claim", { claimId });
|
|
1585
|
+
*/
|
|
1586
|
+
runFunction(name: string, parameters?: Record<string, unknown>): Promise<RunEnvelope>;
|
|
1587
|
+
/**
|
|
1588
|
+
* Fetch a run's current state, including its `Result` once it has one.
|
|
1589
|
+
*
|
|
1590
|
+
* @example
|
|
1591
|
+
* const run = await kf.app.getFunctionRun(runId);
|
|
1592
|
+
* if (run.Status === "Success") use(run.Result);
|
|
1593
|
+
*/
|
|
1594
|
+
getFunctionRun(runId: string): Promise<RunEnvelope>;
|
|
1595
|
+
/**
|
|
1596
|
+
* Be told when a Background run reaches a terminal state.
|
|
1597
|
+
*
|
|
1598
|
+
* Fires `callBack` once with the run's envelope. "Complete" means the run
|
|
1599
|
+
* stopped, not that it worked: it fires on `Failed` and `TimedOut` just as
|
|
1600
|
+
* it does on `Success`, so read `Status` before trusting `Result`. If the
|
|
1601
|
+
* host cannot watch the run at all, `onError` is called instead of
|
|
1602
|
+
* `callBack` ever firing: an older host (`FUNCTION_HOST_UNSUPPORTED`), a
|
|
1603
|
+
* refusal, or the watch limit (`FUNCTION_OBSERVATION_STOPPED`, after about
|
|
1604
|
+
* ten minutes; the run may still finish, so read it later with
|
|
1605
|
+
* {@link getFunctionRun}). At most one of the two is called, at most once.
|
|
1606
|
+
*
|
|
1607
|
+
* Returns a function that unsubscribes. The callback lives only as long as
|
|
1608
|
+
* the script that registered it: form events end their script after 60 s
|
|
1609
|
+
* and a page event ends the previous one when it fires again, while a
|
|
1610
|
+
* Background run may take up to 600 s. Prefer polling {@link getFunctionRun} from a
|
|
1611
|
+
* script that outlives the run, or re-attach after the script restarts.
|
|
1612
|
+
*
|
|
1613
|
+
* @example
|
|
1614
|
+
* const stop = kf.app.onFunctionRunComplete(run.RunId, (done) => show(done), (err) => warn(err));
|
|
1615
|
+
* // later, e.g. on unmount — the host stops watching the run too
|
|
1616
|
+
* stop();
|
|
1617
|
+
*/
|
|
1618
|
+
onFunctionRunComplete(runId: string, callBack: (run: RunEnvelope) => void, onError?: (error: RunWatchError) => void): () => void;
|
|
1470
1619
|
getDecisionTable(flowId: string): DecisionTable;
|
|
1471
1620
|
/**
|
|
1472
1621
|
* Get a published Custom Agent of this app by its id. The handle sends no request until you call one
|
|
@@ -1477,6 +1626,14 @@ declare module "app/index" {
|
|
|
1477
1626
|
* const { ExecutionId } = await agent.execute({ inputData: { request: "Two desks" } });
|
|
1478
1627
|
*/
|
|
1479
1628
|
getAgent(agentId: string): Agent;
|
|
1629
|
+
/**
|
|
1630
|
+
* Get a flow report of this app: one call returns the report's calculated data instead of every record.
|
|
1631
|
+
*
|
|
1632
|
+
* @example
|
|
1633
|
+
* const report = kf.app.getReport("Process", "Leave_Request_A00", "Requests_by_status_x1Yz");
|
|
1634
|
+
* const { Data } = await report.getData();
|
|
1635
|
+
*/
|
|
1636
|
+
getReport(flowType: ReportFlowType, flowId: string, reportId: string): Report;
|
|
1480
1637
|
getDataform(flowId: string): Dataform;
|
|
1481
1638
|
getBoard(flowId: string): Board;
|
|
1482
1639
|
getProcess(flowId: string): Process;
|
|
@@ -1520,6 +1677,7 @@ declare module "app/index" {
|
|
|
1520
1677
|
}
|
|
1521
1678
|
export * from "app/component";
|
|
1522
1679
|
export { Agent };
|
|
1680
|
+
export { Report };
|
|
1523
1681
|
export { Page };
|
|
1524
1682
|
export * from "app/popup";
|
|
1525
1683
|
}
|