@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/lowcode.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;
|
|
@@ -393,6 +401,34 @@ declare module "types/external" {
|
|
|
393
401
|
payload?: PayloadOptions;
|
|
394
402
|
};
|
|
395
403
|
export type DataformQueryResponse = QueryResponse;
|
|
404
|
+
export type ReportFlowType = "Form" | "Process" | "Case";
|
|
405
|
+
export type ReportPayload = {
|
|
406
|
+
FilterParam?: Record<string, string | string[] | object>;
|
|
407
|
+
};
|
|
408
|
+
export type ReportQueryOptions = {
|
|
409
|
+
pageNumber?: number;
|
|
410
|
+
pageSize?: number;
|
|
411
|
+
payload?: ReportPayload;
|
|
412
|
+
};
|
|
413
|
+
export type ReportCountOptions = {
|
|
414
|
+
payload?: ReportPayload;
|
|
415
|
+
};
|
|
416
|
+
export type ReportField = {
|
|
417
|
+
Id: string;
|
|
418
|
+
Name: string;
|
|
419
|
+
[key: string]: any;
|
|
420
|
+
};
|
|
421
|
+
export type ReportDataResponse = {
|
|
422
|
+
Data: any[];
|
|
423
|
+
Columns?: any[];
|
|
424
|
+
Rows?: any[];
|
|
425
|
+
Values?: any[];
|
|
426
|
+
FieldMapping?: any[];
|
|
427
|
+
Formatting?: any[];
|
|
428
|
+
Id?: string;
|
|
429
|
+
Name?: string;
|
|
430
|
+
[key: string]: any;
|
|
431
|
+
};
|
|
396
432
|
export type DataformCreateItemOptions = {
|
|
397
433
|
data?: object;
|
|
398
434
|
viewId?: string;
|
|
@@ -459,6 +495,37 @@ declare module "types/external" {
|
|
|
459
495
|
tableId?: string;
|
|
460
496
|
tableRowId?: string;
|
|
461
497
|
};
|
|
498
|
+
/** The terminal states a Custom Function run ends in, plus the two it passes through. */
|
|
499
|
+
export type RunStatus = "Queued" | "Running" | "Success" | "Failed" | "TimedOut";
|
|
500
|
+
/**
|
|
501
|
+
* What a Custom Function run looks like from the SDK.
|
|
502
|
+
*
|
|
503
|
+
* An Interactive function resolves with the terminal envelope directly. A
|
|
504
|
+
* Background function resolves with `Queued` and only `RunId`; fetch the rest
|
|
505
|
+
* with `getFunctionRun`, or wait for it with `onFunctionRunComplete`.
|
|
506
|
+
*/
|
|
507
|
+
export type RunEnvelope = {
|
|
508
|
+
RunId: string;
|
|
509
|
+
Status: RunStatus;
|
|
510
|
+
/** Whatever the function returned. Only constrained when its output contract names properties. */
|
|
511
|
+
Result?: unknown;
|
|
512
|
+
Error?: {
|
|
513
|
+
Code?: string;
|
|
514
|
+
Message: string;
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* How a Custom Function call fails: `error` is the message text and `errorCode` either the platform
|
|
519
|
+
* code (`KISSFLOW_ERROR_…`) or a `FUNCTION_…` code, including `FUNCTION_HOST_TIMEOUT`,
|
|
520
|
+
* `FUNCTION_REQUEST_NOT_SENT`, `FUNCTION_RUN_OUTCOME_UNKNOWN` (a run may have started),
|
|
521
|
+
* `FUNCTION_RUN_NOT_SENT` (no run started), `FUNCTION_HOST_UNSUPPORTED`, `FUNCTION_WATCH_INVALID_EVENT`
|
|
522
|
+
* and `FUNCTION_OBSERVATION_STOPPED`. The list may grow; fall back to `error` for an unknown code.
|
|
523
|
+
*/
|
|
524
|
+
export type RunWatchError = {
|
|
525
|
+
isError: true;
|
|
526
|
+
error?: string;
|
|
527
|
+
errorCode?: string;
|
|
528
|
+
};
|
|
462
529
|
export type AgentInputDataType = "Text" | "Number" | "Boolean" | "Attachment";
|
|
463
530
|
export type AgentOutputDataType = "string" | "number" | "boolean";
|
|
464
531
|
export type AgentInputField = {
|
|
@@ -985,6 +1052,33 @@ declare module "app/agent" {
|
|
|
985
1052
|
onExecutionComplete(executionId: string, onComplete: (execution: AgentExecution) => void, onWatchError?: (error: AgentError) => void): () => void;
|
|
986
1053
|
}
|
|
987
1054
|
}
|
|
1055
|
+
declare module "app/report" {
|
|
1056
|
+
import { BaseSDK } from "core/index";
|
|
1057
|
+
import { ReportFlowType, ReportQueryOptions, ReportCountOptions, ReportField, ReportDataResponse } from "types/external";
|
|
1058
|
+
/**
|
|
1059
|
+
* A flow report of the current app. The handle sends no request until you call one of its methods.
|
|
1060
|
+
*
|
|
1061
|
+
* @example
|
|
1062
|
+
* const report = kf.app.getReport("Process", "Leave_Request_A00", "Requests_by_status_x1Yz");
|
|
1063
|
+
* const { Data } = await report.getData();
|
|
1064
|
+
*/
|
|
1065
|
+
export class Report extends BaseSDK {
|
|
1066
|
+
private _flowType;
|
|
1067
|
+
private _flowId;
|
|
1068
|
+
private _id;
|
|
1069
|
+
constructor(flowType: ReportFlowType, flowId: string, reportId: string);
|
|
1070
|
+
/**
|
|
1071
|
+
* The report's calculated rows: groups and their values for a chart, the aggregate for a card.
|
|
1072
|
+
* @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")
|
|
1073
|
+
*/
|
|
1074
|
+
getData(options?: ReportQueryOptions): Promise<ReportDataResponse>;
|
|
1075
|
+
/** The number of rows a tabular report would return. Chart and card reports have no row count; use getData(). */
|
|
1076
|
+
getCount(options?: ReportCountOptions): Promise<number>;
|
|
1077
|
+
/** The fields of a tabular report. Empty for chart and card reports; use getData(). */
|
|
1078
|
+
getFields(): Promise<ReportField[]>;
|
|
1079
|
+
private _send;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
988
1082
|
declare module "dataform/index" {
|
|
989
1083
|
import { BaseSDK } from "core/index";
|
|
990
1084
|
import { Form } from "form/index";
|
|
@@ -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
|
}
|
package/dist/lowcode.types.d.ts
CHANGED
|
@@ -302,6 +302,17 @@ declare class Agent {
|
|
|
302
302
|
*/
|
|
303
303
|
onExecutionComplete(executionId: string, onComplete: (execution: AgentExecution) => void, onWatchError?: (error: AgentError) => void): () => void;
|
|
304
304
|
}
|
|
305
|
+
declare class Report {
|
|
306
|
+
/**
|
|
307
|
+
* The report's calculated rows: groups and their values for a chart, the aggregate for a card.
|
|
308
|
+
* @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")
|
|
309
|
+
*/
|
|
310
|
+
getData(options?: ReportQueryOptions): Promise<ReportDataResponse>;
|
|
311
|
+
/** The number of rows a tabular report would return. Chart and card reports have no row count; use getData(). */
|
|
312
|
+
getCount(options?: ReportCountOptions): Promise<number>;
|
|
313
|
+
/** The fields of a tabular report. Empty for chart and card reports; use getData(). */
|
|
314
|
+
getFields(): Promise<ReportField[]>;
|
|
315
|
+
}
|
|
305
316
|
declare class Dataform {
|
|
306
317
|
/**
|
|
307
318
|
* Get all items from this dataform with optional filtering, sorting, and pagination
|
|
@@ -752,6 +763,59 @@ declare class Application {
|
|
|
752
763
|
getVariable(key: string): any;
|
|
753
764
|
setVariable(key: string | object, value?: any): any;
|
|
754
765
|
openPage(pageId: string, pageParams?: object): any;
|
|
766
|
+
/**
|
|
767
|
+
* Run a published Custom Function by name.
|
|
768
|
+
*
|
|
769
|
+
* An Interactive function resolves with its terminal envelope. A Background
|
|
770
|
+
* function resolves as soon as it is queued, with `Status: "Queued"` and a
|
|
771
|
+
* `RunId`; use {@link getFunctionRun} or {@link onFunctionRunComplete} for its result.
|
|
772
|
+
*
|
|
773
|
+
* A refused run rejects with the platform's SDK error shape: the message
|
|
774
|
+
* text is in `error` and the code (`KISSFLOW_ERROR_…`) in `errorCode`.
|
|
775
|
+
* A host that does not answer within 45 s rejects with
|
|
776
|
+
* `FUNCTION_RUN_OUTCOME_UNKNOWN`: the run may still have started, so tell
|
|
777
|
+
* the user instead of starting another.
|
|
778
|
+
*
|
|
779
|
+
* Custom Functions are application-scoped: this is reachable from page,
|
|
780
|
+
* component and flow event scripts that run inside an application, where
|
|
781
|
+
* `kf.app` exists. There is no `kf.app` outside one.
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* const run = await kf.app.runFunction("review_expense_claim", { claimId });
|
|
785
|
+
*/
|
|
786
|
+
runFunction(name: string, parameters?: Record<string, unknown>): Promise<RunEnvelope>;
|
|
787
|
+
/**
|
|
788
|
+
* Fetch a run's current state, including its `Result` once it has one.
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* const run = await kf.app.getFunctionRun(runId);
|
|
792
|
+
* if (run.Status === "Success") use(run.Result);
|
|
793
|
+
*/
|
|
794
|
+
getFunctionRun(runId: string): Promise<RunEnvelope>;
|
|
795
|
+
/**
|
|
796
|
+
* Be told when a Background run reaches a terminal state.
|
|
797
|
+
*
|
|
798
|
+
* Fires `callBack` once with the run's envelope. "Complete" means the run
|
|
799
|
+
* stopped, not that it worked: it fires on `Failed` and `TimedOut` just as
|
|
800
|
+
* it does on `Success`, so read `Status` before trusting `Result`. If the
|
|
801
|
+
* host cannot watch the run at all, `onError` is called instead of
|
|
802
|
+
* `callBack` ever firing: an older host (`FUNCTION_HOST_UNSUPPORTED`), a
|
|
803
|
+
* refusal, or the watch limit (`FUNCTION_OBSERVATION_STOPPED`, after about
|
|
804
|
+
* ten minutes; the run may still finish, so read it later with
|
|
805
|
+
* {@link getFunctionRun}). At most one of the two is called, at most once.
|
|
806
|
+
*
|
|
807
|
+
* Returns a function that unsubscribes. The callback lives only as long as
|
|
808
|
+
* the script that registered it: form events end their script after 60 s
|
|
809
|
+
* and a page event ends the previous one when it fires again, while a
|
|
810
|
+
* Background run may take up to 600 s. Prefer polling {@link getFunctionRun} from a
|
|
811
|
+
* script that outlives the run, or re-attach after the script restarts.
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* const stop = kf.app.onFunctionRunComplete(run.RunId, (done) => show(done), (err) => warn(err));
|
|
815
|
+
* // later, e.g. on unmount — the host stops watching the run too
|
|
816
|
+
* stop();
|
|
817
|
+
*/
|
|
818
|
+
onFunctionRunComplete(runId: string, callBack: (run: RunEnvelope) => void, onError?: (error: RunWatchError) => void): () => void;
|
|
755
819
|
getDecisionTable(flowId: string): DecisionTable;
|
|
756
820
|
/**
|
|
757
821
|
* Get a published Custom Agent of this app by its id. The handle sends no request until you call one
|
|
@@ -762,6 +826,14 @@ declare class Application {
|
|
|
762
826
|
* const { ExecutionId } = await agent.execute({ inputData: { request: "Two desks" } });
|
|
763
827
|
*/
|
|
764
828
|
getAgent(agentId: string): Agent;
|
|
829
|
+
/**
|
|
830
|
+
* Get a flow report of this app: one call returns the report's calculated data instead of every record.
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* const report = kf.app.getReport("Process", "Leave_Request_A00", "Requests_by_status_x1Yz");
|
|
834
|
+
* const { Data } = await report.getData();
|
|
835
|
+
*/
|
|
836
|
+
getReport(flowType: ReportFlowType, flowId: string, reportId: string): Report;
|
|
765
837
|
getDataform(flowId: string): Dataform;
|
|
766
838
|
getBoard(flowId: string): Board;
|
|
767
839
|
getProcess(flowId: string): Process;
|
|
@@ -1065,6 +1137,51 @@ declare type DataformQueryOptions = BaseQueryOptions & {
|
|
|
1065
1137
|
|
|
1066
1138
|
declare type DataformQueryResponse = QueryResponse;
|
|
1067
1139
|
|
|
1140
|
+
// ============================================
|
|
1141
|
+
// Report Types
|
|
1142
|
+
// ============================================
|
|
1143
|
+
|
|
1144
|
+
declare type ReportFlowType = "Form" | "Process" | "Case";
|
|
1145
|
+
|
|
1146
|
+
// The request body of a report read. Only FilterParam is read: it sets the report's open parameters, each named with
|
|
1147
|
+
// a leading $ and sent as text ({ "$status": "Completed" }). Any other key is ignored.
|
|
1148
|
+
declare type ReportPayload = {
|
|
1149
|
+
FilterParam?: Record<string, string | string[] | object>;
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
declare type ReportQueryOptions = {
|
|
1153
|
+
pageNumber?: number;
|
|
1154
|
+
pageSize?: number;
|
|
1155
|
+
payload?: ReportPayload;
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
declare type ReportCountOptions = {
|
|
1159
|
+
payload?: ReportPayload;
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
// A field of a tabular report. The report service may add keys such as Type.
|
|
1163
|
+
declare type ReportField = {
|
|
1164
|
+
Id: string;
|
|
1165
|
+
Name: string;
|
|
1166
|
+
[key: string]: any;
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
// Which of these keys come back depends on the report's type: a chart has Columns and Values (and Rows with a
|
|
1170
|
+
// series), a card has FieldMapping and Values (its Data is empty when nothing matches), a tabular report has
|
|
1171
|
+
// Columns, Id and Name, a pivot has Columns, Rows, Values and Formatting. Each Data row is keyed by the Id of its
|
|
1172
|
+
// Columns, Rows or Values entry.
|
|
1173
|
+
declare type ReportDataResponse = {
|
|
1174
|
+
Data: any[];
|
|
1175
|
+
Columns?: any[];
|
|
1176
|
+
Rows?: any[];
|
|
1177
|
+
Values?: any[];
|
|
1178
|
+
FieldMapping?: any[];
|
|
1179
|
+
Formatting?: any[];
|
|
1180
|
+
Id?: string;
|
|
1181
|
+
Name?: string;
|
|
1182
|
+
[key: string]: any;
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1068
1185
|
declare type DataformCreateItemOptions = {
|
|
1069
1186
|
data?: object;
|
|
1070
1187
|
viewId?: string;
|
|
@@ -1151,6 +1268,33 @@ declare type BoardFieldOptions = {
|
|
|
1151
1268
|
tableRowId?: string;
|
|
1152
1269
|
};
|
|
1153
1270
|
|
|
1271
|
+
/** The terminal states a Custom Function run ends in, plus the two it passes through. */
|
|
1272
|
+
declare type RunStatus = "Queued" | "Running" | "Success" | "Failed" | "TimedOut";
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* What a Custom Function run looks like from the SDK.
|
|
1276
|
+
*
|
|
1277
|
+
* An Interactive function resolves with the terminal envelope directly. A
|
|
1278
|
+
* Background function resolves with `Queued` and only `RunId`; fetch the rest
|
|
1279
|
+
* with `getFunctionRun`, or wait for it with `onFunctionRunComplete`.
|
|
1280
|
+
*/
|
|
1281
|
+
declare type RunEnvelope = {
|
|
1282
|
+
RunId: string;
|
|
1283
|
+
Status: RunStatus;
|
|
1284
|
+
/** Whatever the function returned. Only constrained when its output contract names properties. */
|
|
1285
|
+
Result?: unknown;
|
|
1286
|
+
Error?: { Code?: string; Message: string };
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* How a Custom Function call fails: `error` is the message text and `errorCode` either the platform
|
|
1291
|
+
* code (`KISSFLOW_ERROR_…`) or a `FUNCTION_…` code, including `FUNCTION_HOST_TIMEOUT`,
|
|
1292
|
+
* `FUNCTION_REQUEST_NOT_SENT`, `FUNCTION_RUN_OUTCOME_UNKNOWN` (a run may have started),
|
|
1293
|
+
* `FUNCTION_RUN_NOT_SENT` (no run started), `FUNCTION_HOST_UNSUPPORTED`, `FUNCTION_WATCH_INVALID_EVENT`
|
|
1294
|
+
* and `FUNCTION_OBSERVATION_STOPPED`. The list may grow; fall back to `error` for an unknown code.
|
|
1295
|
+
*/
|
|
1296
|
+
declare type RunWatchError = { isError: true; error?: string; errorCode?: string };
|
|
1297
|
+
|
|
1154
1298
|
// ============================================
|
|
1155
1299
|
// Custom Agent Types
|
|
1156
1300
|
// ============================================
|
package/dist/nocode.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;
|
|
@@ -393,6 +401,34 @@ declare module "types/external" {
|
|
|
393
401
|
payload?: PayloadOptions;
|
|
394
402
|
};
|
|
395
403
|
export type DataformQueryResponse = QueryResponse;
|
|
404
|
+
export type ReportFlowType = "Form" | "Process" | "Case";
|
|
405
|
+
export type ReportPayload = {
|
|
406
|
+
FilterParam?: Record<string, string | string[] | object>;
|
|
407
|
+
};
|
|
408
|
+
export type ReportQueryOptions = {
|
|
409
|
+
pageNumber?: number;
|
|
410
|
+
pageSize?: number;
|
|
411
|
+
payload?: ReportPayload;
|
|
412
|
+
};
|
|
413
|
+
export type ReportCountOptions = {
|
|
414
|
+
payload?: ReportPayload;
|
|
415
|
+
};
|
|
416
|
+
export type ReportField = {
|
|
417
|
+
Id: string;
|
|
418
|
+
Name: string;
|
|
419
|
+
[key: string]: any;
|
|
420
|
+
};
|
|
421
|
+
export type ReportDataResponse = {
|
|
422
|
+
Data: any[];
|
|
423
|
+
Columns?: any[];
|
|
424
|
+
Rows?: any[];
|
|
425
|
+
Values?: any[];
|
|
426
|
+
FieldMapping?: any[];
|
|
427
|
+
Formatting?: any[];
|
|
428
|
+
Id?: string;
|
|
429
|
+
Name?: string;
|
|
430
|
+
[key: string]: any;
|
|
431
|
+
};
|
|
396
432
|
export type DataformCreateItemOptions = {
|
|
397
433
|
data?: object;
|
|
398
434
|
viewId?: string;
|
|
@@ -459,6 +495,37 @@ declare module "types/external" {
|
|
|
459
495
|
tableId?: string;
|
|
460
496
|
tableRowId?: string;
|
|
461
497
|
};
|
|
498
|
+
/** The terminal states a Custom Function run ends in, plus the two it passes through. */
|
|
499
|
+
export type RunStatus = "Queued" | "Running" | "Success" | "Failed" | "TimedOut";
|
|
500
|
+
/**
|
|
501
|
+
* What a Custom Function run looks like from the SDK.
|
|
502
|
+
*
|
|
503
|
+
* An Interactive function resolves with the terminal envelope directly. A
|
|
504
|
+
* Background function resolves with `Queued` and only `RunId`; fetch the rest
|
|
505
|
+
* with `getFunctionRun`, or wait for it with `onFunctionRunComplete`.
|
|
506
|
+
*/
|
|
507
|
+
export type RunEnvelope = {
|
|
508
|
+
RunId: string;
|
|
509
|
+
Status: RunStatus;
|
|
510
|
+
/** Whatever the function returned. Only constrained when its output contract names properties. */
|
|
511
|
+
Result?: unknown;
|
|
512
|
+
Error?: {
|
|
513
|
+
Code?: string;
|
|
514
|
+
Message: string;
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* How a Custom Function call fails: `error` is the message text and `errorCode` either the platform
|
|
519
|
+
* code (`KISSFLOW_ERROR_…`) or a `FUNCTION_…` code, including `FUNCTION_HOST_TIMEOUT`,
|
|
520
|
+
* `FUNCTION_REQUEST_NOT_SENT`, `FUNCTION_RUN_OUTCOME_UNKNOWN` (a run may have started),
|
|
521
|
+
* `FUNCTION_RUN_NOT_SENT` (no run started), `FUNCTION_HOST_UNSUPPORTED`, `FUNCTION_WATCH_INVALID_EVENT`
|
|
522
|
+
* and `FUNCTION_OBSERVATION_STOPPED`. The list may grow; fall back to `error` for an unknown code.
|
|
523
|
+
*/
|
|
524
|
+
export type RunWatchError = {
|
|
525
|
+
isError: true;
|
|
526
|
+
error?: string;
|
|
527
|
+
errorCode?: string;
|
|
528
|
+
};
|
|
462
529
|
export type AgentInputDataType = "Text" | "Number" | "Boolean" | "Attachment";
|
|
463
530
|
export type AgentOutputDataType = "string" | "number" | "boolean";
|
|
464
531
|
export type AgentInputField = {
|
|
@@ -1024,6 +1091,33 @@ declare module "app/page" {
|
|
|
1024
1091
|
getRoute(): string;
|
|
1025
1092
|
}
|
|
1026
1093
|
}
|
|
1094
|
+
declare module "app/report" {
|
|
1095
|
+
import { BaseSDK } from "core/index";
|
|
1096
|
+
import { ReportFlowType, ReportQueryOptions, ReportCountOptions, ReportField, ReportDataResponse } from "types/external";
|
|
1097
|
+
/**
|
|
1098
|
+
* A flow report of the current app. The handle sends no request until you call one of its methods.
|
|
1099
|
+
*
|
|
1100
|
+
* @example
|
|
1101
|
+
* const report = kf.app.getReport("Process", "Leave_Request_A00", "Requests_by_status_x1Yz");
|
|
1102
|
+
* const { Data } = await report.getData();
|
|
1103
|
+
*/
|
|
1104
|
+
export class Report extends BaseSDK {
|
|
1105
|
+
private _flowType;
|
|
1106
|
+
private _flowId;
|
|
1107
|
+
private _id;
|
|
1108
|
+
constructor(flowType: ReportFlowType, flowId: string, reportId: string);
|
|
1109
|
+
/**
|
|
1110
|
+
* The report's calculated rows: groups and their values for a chart, the aggregate for a card.
|
|
1111
|
+
* @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")
|
|
1112
|
+
*/
|
|
1113
|
+
getData(options?: ReportQueryOptions): Promise<ReportDataResponse>;
|
|
1114
|
+
/** The number of rows a tabular report would return. Chart and card reports have no row count; use getData(). */
|
|
1115
|
+
getCount(options?: ReportCountOptions): Promise<number>;
|
|
1116
|
+
/** The fields of a tabular report. Empty for chart and card reports; use getData(). */
|
|
1117
|
+
getFields(): Promise<ReportField[]>;
|
|
1118
|
+
private _send;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1027
1121
|
declare module "dataform/index" {
|
|
1028
1122
|
import { BaseSDK } from "core/index";
|
|
1029
1123
|
import { Form } from "form/index";
|
|
@@ -1493,19 +1587,74 @@ declare module "app/index" {
|
|
|
1493
1587
|
import { BaseSDK } from "core/index";
|
|
1494
1588
|
import { Page } from "app/page";
|
|
1495
1589
|
import { AppContext } from "types/internal";
|
|
1496
|
-
import { rolesObject } from "types/external";
|
|
1590
|
+
import { rolesObject, ReportFlowType, RunEnvelope, RunWatchError } from "types/external";
|
|
1497
1591
|
import { DecisionTable } from "app/decisiontable";
|
|
1498
1592
|
import { Agent } from "app/agent";
|
|
1593
|
+
import { Report } from "app/report";
|
|
1499
1594
|
import { Dataform } from "dataform/index";
|
|
1500
1595
|
import { Board } from "board/index";
|
|
1501
1596
|
import { Process } from "process/index";
|
|
1502
1597
|
export class Application extends BaseSDK {
|
|
1503
1598
|
page: Page;
|
|
1504
1599
|
_id: string;
|
|
1600
|
+
private activeWatches;
|
|
1505
1601
|
constructor(props: AppContext, isCustomComponent?: boolean);
|
|
1506
1602
|
getVariable(key: string): any;
|
|
1507
1603
|
setVariable(key: string | object, value?: any): any;
|
|
1508
1604
|
openPage(pageId: string, pageParams?: object): any;
|
|
1605
|
+
/**
|
|
1606
|
+
* Run a published Custom Function by name.
|
|
1607
|
+
*
|
|
1608
|
+
* An Interactive function resolves with its terminal envelope. A Background
|
|
1609
|
+
* function resolves as soon as it is queued, with `Status: "Queued"` and a
|
|
1610
|
+
* `RunId`; use {@link getFunctionRun} or {@link onFunctionRunComplete} for its result.
|
|
1611
|
+
*
|
|
1612
|
+
* A refused run rejects with the platform's SDK error shape: the message
|
|
1613
|
+
* text is in `error` and the code (`KISSFLOW_ERROR_…`) in `errorCode`.
|
|
1614
|
+
* A host that does not answer within 45 s rejects with
|
|
1615
|
+
* `FUNCTION_RUN_OUTCOME_UNKNOWN`: the run may still have started, so tell
|
|
1616
|
+
* the user instead of starting another.
|
|
1617
|
+
*
|
|
1618
|
+
* Custom Functions are application-scoped: this is reachable from page,
|
|
1619
|
+
* component and flow event scripts that run inside an application, where
|
|
1620
|
+
* `kf.app` exists. There is no `kf.app` outside one.
|
|
1621
|
+
*
|
|
1622
|
+
* @example
|
|
1623
|
+
* const run = await kf.app.runFunction("review_expense_claim", { claimId });
|
|
1624
|
+
*/
|
|
1625
|
+
runFunction(name: string, parameters?: Record<string, unknown>): Promise<RunEnvelope>;
|
|
1626
|
+
/**
|
|
1627
|
+
* Fetch a run's current state, including its `Result` once it has one.
|
|
1628
|
+
*
|
|
1629
|
+
* @example
|
|
1630
|
+
* const run = await kf.app.getFunctionRun(runId);
|
|
1631
|
+
* if (run.Status === "Success") use(run.Result);
|
|
1632
|
+
*/
|
|
1633
|
+
getFunctionRun(runId: string): Promise<RunEnvelope>;
|
|
1634
|
+
/**
|
|
1635
|
+
* Be told when a Background run reaches a terminal state.
|
|
1636
|
+
*
|
|
1637
|
+
* Fires `callBack` once with the run's envelope. "Complete" means the run
|
|
1638
|
+
* stopped, not that it worked: it fires on `Failed` and `TimedOut` just as
|
|
1639
|
+
* it does on `Success`, so read `Status` before trusting `Result`. If the
|
|
1640
|
+
* host cannot watch the run at all, `onError` is called instead of
|
|
1641
|
+
* `callBack` ever firing: an older host (`FUNCTION_HOST_UNSUPPORTED`), a
|
|
1642
|
+
* refusal, or the watch limit (`FUNCTION_OBSERVATION_STOPPED`, after about
|
|
1643
|
+
* ten minutes; the run may still finish, so read it later with
|
|
1644
|
+
* {@link getFunctionRun}). At most one of the two is called, at most once.
|
|
1645
|
+
*
|
|
1646
|
+
* Returns a function that unsubscribes. The callback lives only as long as
|
|
1647
|
+
* the script that registered it: form events end their script after 60 s
|
|
1648
|
+
* and a page event ends the previous one when it fires again, while a
|
|
1649
|
+
* Background run may take up to 600 s. Prefer polling {@link getFunctionRun} from a
|
|
1650
|
+
* script that outlives the run, or re-attach after the script restarts.
|
|
1651
|
+
*
|
|
1652
|
+
* @example
|
|
1653
|
+
* const stop = kf.app.onFunctionRunComplete(run.RunId, (done) => show(done), (err) => warn(err));
|
|
1654
|
+
* // later, e.g. on unmount — the host stops watching the run too
|
|
1655
|
+
* stop();
|
|
1656
|
+
*/
|
|
1657
|
+
onFunctionRunComplete(runId: string, callBack: (run: RunEnvelope) => void, onError?: (error: RunWatchError) => void): () => void;
|
|
1509
1658
|
getDecisionTable(flowId: string): DecisionTable;
|
|
1510
1659
|
/**
|
|
1511
1660
|
* Get a published Custom Agent of this app by its id. The handle sends no request until you call one
|
|
@@ -1516,6 +1665,14 @@ declare module "app/index" {
|
|
|
1516
1665
|
* const { ExecutionId } = await agent.execute({ inputData: { request: "Two desks" } });
|
|
1517
1666
|
*/
|
|
1518
1667
|
getAgent(agentId: string): Agent;
|
|
1668
|
+
/**
|
|
1669
|
+
* Get a flow report of this app: one call returns the report's calculated data instead of every record.
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* const report = kf.app.getReport("Process", "Leave_Request_A00", "Requests_by_status_x1Yz");
|
|
1673
|
+
* const { Data } = await report.getData();
|
|
1674
|
+
*/
|
|
1675
|
+
getReport(flowType: ReportFlowType, flowId: string, reportId: string): Report;
|
|
1519
1676
|
getDataform(flowId: string): Dataform;
|
|
1520
1677
|
getBoard(flowId: string): Board;
|
|
1521
1678
|
getProcess(flowId: string): Process;
|
|
@@ -1559,6 +1716,7 @@ declare module "app/index" {
|
|
|
1559
1716
|
}
|
|
1560
1717
|
export * from "app/component";
|
|
1561
1718
|
export { Agent };
|
|
1719
|
+
export { Report };
|
|
1562
1720
|
export { Page };
|
|
1563
1721
|
export * from "app/popup";
|
|
1564
1722
|
}
|