@nocobase/flow-engine 2.0.0-beta.20 → 2.0.0-beta.22
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/lib/JSRunner.js +23 -1
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +3 -3
- package/lib/data-source/index.d.ts +7 -27
- package/lib/data-source/index.js +67 -46
- package/lib/flowContext.d.ts +62 -0
- package/lib/flowContext.js +92 -3
- package/lib/flowEngine.js +18 -8
- package/lib/index.d.ts +4 -1
- package/lib/index.js +5 -0
- package/lib/resources/sqlResource.d.ts +3 -3
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +2 -2
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +125 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/base.js +691 -23
- package/lib/runjs-context/contributions.d.ts +33 -0
- package/lib/runjs-context/contributions.js +88 -0
- package/lib/runjs-context/setup.js +6 -0
- package/lib/runjs-context/snippets/index.d.ts +11 -1
- package/lib/runjs-context/snippets/index.js +61 -40
- package/lib/utils/safeGlobals.js +2 -0
- package/package.json +4 -4
- package/src/JSRunner.ts +29 -1
- package/src/__tests__/JSRunner.test.ts +64 -0
- package/src/__tests__/flowContext.test.ts +90 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +28 -0
- package/src/__tests__/runjsContext.test.ts +4 -1
- package/src/__tests__/runjsLocales.test.ts +4 -1
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +3 -3
- package/src/data-source/index.ts +71 -105
- package/src/flowContext.ts +160 -2
- package/src/flowEngine.ts +18 -8
- package/src/index.ts +4 -1
- package/src/resources/sqlResource.ts +3 -3
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +6 -2
- package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +106 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/base.ts +698 -30
- package/src/runjs-context/contributions.ts +88 -0
- package/src/runjs-context/setup.ts +6 -0
- package/src/runjs-context/snippets/index.ts +75 -41
- package/src/utils/__tests__/safeGlobals.test.ts +8 -0
- package/src/utils/safeGlobals.ts +3 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var JSEditableFieldRunJSContext_exports = {};
|
|
29
|
+
__export(JSEditableFieldRunJSContext_exports, {
|
|
30
|
+
JSEditableFieldRunJSContext: () => JSEditableFieldRunJSContext
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(JSEditableFieldRunJSContext_exports);
|
|
33
|
+
var import_flowContext = require("../../flowContext");
|
|
34
|
+
const _JSEditableFieldRunJSContext = class _JSEditableFieldRunJSContext extends import_flowContext.FlowRunJSContext {
|
|
35
|
+
};
|
|
36
|
+
__name(_JSEditableFieldRunJSContext, "JSEditableFieldRunJSContext");
|
|
37
|
+
let JSEditableFieldRunJSContext = _JSEditableFieldRunJSContext;
|
|
38
|
+
JSEditableFieldRunJSContext.define({
|
|
39
|
+
label: "JSEditableField RunJS context",
|
|
40
|
+
properties: {
|
|
41
|
+
element: {
|
|
42
|
+
description: "ElementProxy instance providing a safe DOM container for field rendering. In editable mode this container is typically a <span> element.",
|
|
43
|
+
detail: "ElementProxy"
|
|
44
|
+
},
|
|
45
|
+
value: {
|
|
46
|
+
description: "Current field value (read-only snapshot). In editable scenarios, prefer ctx.getValue()/ctx.setValue(v) for two-way binding.",
|
|
47
|
+
detail: "any",
|
|
48
|
+
examples: ["const v = ctx.getValue?.() ?? ctx.value;", 'ctx.setValue?.("new value");']
|
|
49
|
+
},
|
|
50
|
+
record: {
|
|
51
|
+
description: "Current record data object (read-only). Available in forms that are bound to a record.",
|
|
52
|
+
detail: "Record<string, any>"
|
|
53
|
+
},
|
|
54
|
+
form: {
|
|
55
|
+
description: 'Ant Design Form instance for reading/writing other fields. Example: ctx.form.getFieldValue("name")',
|
|
56
|
+
detail: "FormInstance"
|
|
57
|
+
},
|
|
58
|
+
formValues: {
|
|
59
|
+
description: "Snapshot of current form values (object). Prefer ctx.form.getFieldsValue() when you need the latest values.",
|
|
60
|
+
detail: "Record<string, any>"
|
|
61
|
+
},
|
|
62
|
+
namePath: {
|
|
63
|
+
description: "Field namePath in the form (array). Useful for advanced Form operations.",
|
|
64
|
+
detail: "Array<string | number>"
|
|
65
|
+
},
|
|
66
|
+
disabled: "Whether the field is disabled (boolean).",
|
|
67
|
+
readOnly: "Whether the field is read-only (boolean)."
|
|
68
|
+
},
|
|
69
|
+
methods: {
|
|
70
|
+
getValue: {
|
|
71
|
+
description: "Get current field value (recommended for editable custom fields).",
|
|
72
|
+
detail: "() => any",
|
|
73
|
+
completion: { insertText: "ctx.getValue?.()" }
|
|
74
|
+
},
|
|
75
|
+
setValue: {
|
|
76
|
+
description: "Set current field value (two-way binding with the form).",
|
|
77
|
+
detail: "(value: any) => void",
|
|
78
|
+
completion: { insertText: "ctx.setValue?.(value)" },
|
|
79
|
+
examples: ["ctx.setValue?.(e.target.value);"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
JSEditableFieldRunJSContext.define(
|
|
84
|
+
{
|
|
85
|
+
label: "JS \u53EF\u7F16\u8F91\u5B57\u6BB5 RunJS \u4E0A\u4E0B\u6587",
|
|
86
|
+
properties: {
|
|
87
|
+
element: {
|
|
88
|
+
description: "ElementProxy\uFF0C\u5B57\u6BB5\u6E32\u67D3\u7684\u5B89\u5168\u5BB9\u5668\uFF08\u901A\u5E38\u4E3A <span> \u5BB9\u5668\uFF09\u3002",
|
|
89
|
+
detail: "ElementProxy"
|
|
90
|
+
},
|
|
91
|
+
value: {
|
|
92
|
+
description: "\u5B57\u6BB5\u5F53\u524D\u503C\uFF08\u53EA\u8BFB\u5FEB\u7167\uFF09\u3002\u53EF\u7F16\u8F91\u573A\u666F\u5EFA\u8BAE\u4F7F\u7528 ctx.getValue()/ctx.setValue(v) \u505A\u53CC\u5411\u7ED1\u5B9A\u3002",
|
|
93
|
+
detail: "any",
|
|
94
|
+
examples: ["const v = ctx.getValue?.() ?? ctx.value;", 'ctx.setValue?.("\u65B0\u503C");']
|
|
95
|
+
},
|
|
96
|
+
record: { description: "\u5F53\u524D\u8BB0\u5F55\u5BF9\u8C61\uFF08\u53EA\u8BFB\uFF1B\u8868\u5355\u7ED1\u5B9A\u8BB0\u5F55\u65F6\u53EF\u7528\uFF09\u3002", detail: "Record<string, any>" },
|
|
97
|
+
form: { description: "Ant Design Form \u5B9E\u4F8B\uFF0C\u53EF\u8BFB\u5199\u5176\u5B83\u5B57\u6BB5\u3002", detail: "FormInstance" },
|
|
98
|
+
formValues: {
|
|
99
|
+
description: "\u5F53\u524D\u8868\u5355\u503C\u5FEB\u7167\uFF08\u5BF9\u8C61\uFF09\u3002\u9700\u8981\u6700\u65B0\u503C\u53EF\u7528 ctx.form.getFieldsValue()\u3002",
|
|
100
|
+
detail: "Record<string, any>"
|
|
101
|
+
},
|
|
102
|
+
namePath: { description: "\u5B57\u6BB5\u5728\u8868\u5355\u4E2D\u7684 namePath\uFF08\u6570\u7EC4\uFF09\u3002", detail: "Array<string | number>" },
|
|
103
|
+
disabled: "\u662F\u5426\u7981\u7528\uFF08boolean\uFF09",
|
|
104
|
+
readOnly: "\u662F\u5426\u53EA\u8BFB\uFF08boolean\uFF09"
|
|
105
|
+
},
|
|
106
|
+
methods: {
|
|
107
|
+
getValue: {
|
|
108
|
+
description: "\u83B7\u53D6\u5B57\u6BB5\u5F53\u524D\u503C\uFF08\u53EF\u7F16\u8F91\u5B57\u6BB5\u63A8\u8350\u4F7F\u7528\uFF09\u3002",
|
|
109
|
+
detail: "() => any",
|
|
110
|
+
completion: { insertText: "ctx.getValue?.()" }
|
|
111
|
+
},
|
|
112
|
+
setValue: {
|
|
113
|
+
description: "\u8BBE\u7F6E\u5B57\u6BB5\u5F53\u524D\u503C\uFF08\u4E0E\u8868\u5355\u53CC\u5411\u7ED1\u5B9A\uFF09\u3002",
|
|
114
|
+
detail: "(value: any) => void",
|
|
115
|
+
completion: { insertText: "ctx.setValue?.(value)" },
|
|
116
|
+
examples: ["ctx.setValue?.(e.target.value);"]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{ locale: "zh-CN" }
|
|
121
|
+
);
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
JSEditableFieldRunJSContext
|
|
125
|
+
});
|
|
@@ -43,7 +43,12 @@ JSItemRunJSContext.define({
|
|
|
43
43
|
resource: `Current resource instance (read-only).
|
|
44
44
|
Provides access to the data resource associated with the current form context.`,
|
|
45
45
|
record: `Current record data object (read-only).
|
|
46
|
-
Contains all field values of the parent record
|
|
46
|
+
Contains all field values of the parent record.`,
|
|
47
|
+
formValues: {
|
|
48
|
+
description: "Snapshot of current form values (object). Available in form contexts (CreateForm/EditForm).",
|
|
49
|
+
detail: "Record<string, any>",
|
|
50
|
+
examples: ["const { name, status } = ctx.formValues || {};"]
|
|
51
|
+
}
|
|
47
52
|
},
|
|
48
53
|
methods: {
|
|
49
54
|
onRefReady: `Wait for form item container DOM element to be ready before executing callback.
|
|
@@ -56,7 +61,12 @@ JSItemRunJSContext.define(
|
|
|
56
61
|
properties: {
|
|
57
62
|
element: "ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",
|
|
58
63
|
resource: "\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",
|
|
59
|
-
record: "\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09"
|
|
64
|
+
record: "\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09",
|
|
65
|
+
formValues: {
|
|
66
|
+
description: "\u5F53\u524D\u8868\u5355\u503C\u5FEB\u7167\uFF08\u5BF9\u8C61\uFF09\u3002\u4EC5\u8868\u5355\u76F8\u5173\u4E0A\u4E0B\u6587\u53EF\u7528\uFF08Create/Edit Form\uFF09\u3002",
|
|
67
|
+
detail: "Record<string, any>",
|
|
68
|
+
examples: ["const { name, status } = ctx.formValues || {};"]
|
|
69
|
+
}
|
|
60
70
|
},
|
|
61
71
|
methods: {
|
|
62
72
|
onRefReady: "\u5BB9\u5668\u5C31\u7EEA\u540E\u6267\u884C\u56DE\u8C03\u3002\u53C2\u6570\uFF1A(ref, callback, timeout?)"
|