@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.
@@ -475,6 +475,51 @@ declare type DataformQueryOptions = BaseQueryOptions & {
475
475
 
476
476
  declare type DataformQueryResponse = QueryResponse;
477
477
 
478
+ // ============================================
479
+ // Report Types
480
+ // ============================================
481
+
482
+ declare type ReportFlowType = "Form" | "Process" | "Case";
483
+
484
+ // The request body of a report read. Only FilterParam is read: it sets the report's open parameters, each named with
485
+ // a leading $ and sent as text ({ "$status": "Completed" }). Any other key is ignored.
486
+ declare type ReportPayload = {
487
+ FilterParam?: Record<string, string | string[] | object>;
488
+ };
489
+
490
+ declare type ReportQueryOptions = {
491
+ pageNumber?: number;
492
+ pageSize?: number;
493
+ payload?: ReportPayload;
494
+ };
495
+
496
+ declare type ReportCountOptions = {
497
+ payload?: ReportPayload;
498
+ };
499
+
500
+ // A field of a tabular report. The report service may add keys such as Type.
501
+ declare type ReportField = {
502
+ Id: string;
503
+ Name: string;
504
+ [key: string]: any;
505
+ };
506
+
507
+ // Which of these keys come back depends on the report's type: a chart has Columns and Values (and Rows with a
508
+ // series), a card has FieldMapping and Values (its Data is empty when nothing matches), a tabular report has
509
+ // Columns, Id and Name, a pivot has Columns, Rows, Values and Formatting. Each Data row is keyed by the Id of its
510
+ // Columns, Rows or Values entry.
511
+ declare type ReportDataResponse = {
512
+ Data: any[];
513
+ Columns?: any[];
514
+ Rows?: any[];
515
+ Values?: any[];
516
+ FieldMapping?: any[];
517
+ Formatting?: any[];
518
+ Id?: string;
519
+ Name?: string;
520
+ [key: string]: any;
521
+ };
522
+
478
523
  declare type DataformCreateItemOptions = {
479
524
  data?: object;
480
525
  viewId?: string;
@@ -561,6 +606,33 @@ declare type BoardFieldOptions = {
561
606
  tableRowId?: string;
562
607
  };
563
608
 
609
+ /** The terminal states a Custom Function run ends in, plus the two it passes through. */
610
+ declare type RunStatus = "Queued" | "Running" | "Success" | "Failed" | "TimedOut";
611
+
612
+ /**
613
+ * What a Custom Function run looks like from the SDK.
614
+ *
615
+ * An Interactive function resolves with the terminal envelope directly. A
616
+ * Background function resolves with `Queued` and only `RunId`; fetch the rest
617
+ * with `getFunctionRun`, or wait for it with `onFunctionRunComplete`.
618
+ */
619
+ declare type RunEnvelope = {
620
+ RunId: string;
621
+ Status: RunStatus;
622
+ /** Whatever the function returned. Only constrained when its output contract names properties. */
623
+ Result?: unknown;
624
+ Error?: { Code?: string; Message: string };
625
+ };
626
+
627
+ /**
628
+ * How a Custom Function call fails: `error` is the message text and `errorCode` either the platform
629
+ * code (`KISSFLOW_ERROR_…`) or a `FUNCTION_…` code, including `FUNCTION_HOST_TIMEOUT`,
630
+ * `FUNCTION_REQUEST_NOT_SENT`, `FUNCTION_RUN_OUTCOME_UNKNOWN` (a run may have started),
631
+ * `FUNCTION_RUN_NOT_SENT` (no run started), `FUNCTION_HOST_UNSUPPORTED`, `FUNCTION_WATCH_INVALID_EVENT`
632
+ * and `FUNCTION_OBSERVATION_STOPPED`. The list may grow; fall back to `error` for an unknown code.
633
+ */
634
+ declare type RunWatchError = { isError: true; error?: string; errorCode?: string };
635
+
564
636
  // ============================================
565
637
  // Custom Agent Types
566
638
  // ============================================
@@ -20,11 +20,31 @@
20
20
  "documentation": "Evaluates the provided data and returns back the matched output",
21
21
  "insertText": "let decisionTableInstance = kf.app.getDecisionTable(\"${1:flowId}\");\n let decisionOutput = await decisionTableInstance.evaluate({ conditionField1: \"value\", conditionField2: \"value\" });"
22
22
  },
23
+ {
24
+ "label": "run custom function",
25
+ "documentation": "Run a Custom Function; a Background function returns only RunId and Status: \"Queued\"",
26
+ "insertText": "let run = await kf.app.runFunction(\"${1:functionName}\", { ${2:key}: \"${3:value}\" });"
27
+ },
28
+ {
29
+ "label": "get custom function run",
30
+ "documentation": "Fetch a Custom Function run's status, and its Result once it has one",
31
+ "insertText": "let run = await kf.app.getFunctionRun(\"${1:runId}\");"
32
+ },
33
+ {
34
+ "label": "on custom function run complete",
35
+ "documentation": "Called once when a Background run reaches Success, Failed or TimedOut; the returned function unsubscribes",
36
+ "insertText": "let stop = kf.app.onFunctionRunComplete(\"${1:runId}\", (run) => {\n\t${2:// run.Status, run.Result}\n}, (err) => {\n\t${3:// err.error}\n});"
37
+ },
23
38
  {
24
39
  "label": "run custom agent",
25
40
  "documentation": "Runs a published Custom Agent of this app and handles its result when it finishes",
26
41
  "insertText": "let agentInstance = kf.app.getAgent(\"${1:agentId}\");\n let { ExecutionId } = await agentInstance.execute({ inputData: { ${2:inputKey}: ${3:value} } });\n let stopWatching = agentInstance.onExecutionComplete(ExecutionId, (execution) => { let items = execution.Output?.items; }, (error) => console.warn(error.errorCode));"
27
42
  },
43
+ {
44
+ "label": "read report",
45
+ "documentation": "Reads a flow report's calculated data in one call",
46
+ "insertText": "const report = kf.app.getReport(\"${1|Process,Form,Case|}\", \"${2:flowId}\", \"${3:reportId}\");\nconst { Data } = await report.getData();"
47
+ },
28
48
  {
29
49
  "label": "get local variable",
30
50
  "documentation": "Get value of the local variable",
@@ -195,4 +215,4 @@
195
215
  "insertText": "let payload = {}:\nkf.api(`/process/2/${kf.account._id}/${1:processId}/`, {\n\tmethod: \"POST\",\n\tbody: JSON.stringify(payload)\n})\n.then((resp) => {${2}})\n.catch((err) => {${3}})"
196
216
  }
197
217
  ]
198
- }
218
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kissflow/lowcode-client-sdk",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "JavaScript SDK for developing over the Kissflow lowcode platform",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [