@nocobase/flow-engine 2.1.0-beta.9 → 2.1.1
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/FlowContextProvider.d.ts +5 -1
- package/lib/FlowContextProvider.js +9 -2
- package/lib/components/FieldModelRenderer.js +2 -2
- package/lib/components/FlowModelRenderer.d.ts +3 -1
- package/lib/components/FlowModelRenderer.js +12 -6
- package/lib/components/FormItem.d.ts +6 -0
- package/lib/components/FormItem.js +11 -3
- package/lib/components/MobilePopup.js +6 -5
- package/lib/components/dnd/gridDragPlanner.d.ts +59 -2
- package/lib/components/dnd/gridDragPlanner.js +607 -19
- package/lib/components/dnd/index.d.ts +31 -2
- package/lib/components/dnd/index.js +244 -23
- package/lib/components/settings/wrappers/component/SelectWithTitle.d.ts +2 -1
- package/lib/components/settings/wrappers/component/SelectWithTitle.js +14 -12
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +3 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +152 -42
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +23 -43
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +352 -295
- package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.d.ts +36 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.js +274 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.d.ts +30 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.js +315 -0
- package/lib/components/subModel/AddSubModelButton.js +12 -1
- package/lib/components/subModel/LazyDropdown.js +301 -52
- package/lib/components/subModel/index.d.ts +1 -0
- package/lib/components/subModel/index.js +19 -0
- package/lib/components/subModel/utils.d.ts +2 -1
- package/lib/components/subModel/utils.js +15 -5
- package/lib/components/variables/VariableHybridInput.d.ts +27 -0
- package/lib/components/variables/VariableHybridInput.js +499 -0
- package/lib/components/variables/index.d.ts +2 -0
- package/lib/components/variables/index.js +3 -0
- package/lib/data-source/index.d.ts +84 -0
- package/lib/data-source/index.js +269 -7
- package/lib/executor/FlowExecutor.js +6 -3
- package/lib/flow-registry/DetachedFlowRegistry.d.ts +21 -0
- package/lib/flow-registry/DetachedFlowRegistry.js +80 -0
- package/lib/flow-registry/index.d.ts +1 -0
- package/lib/flow-registry/index.js +3 -1
- package/lib/flowContext.d.ts +9 -1
- package/lib/flowContext.js +77 -6
- package/lib/flowEngine.d.ts +136 -4
- package/lib/flowEngine.js +429 -51
- package/lib/flowI18n.js +2 -1
- package/lib/flowSettings.d.ts +14 -6
- package/lib/flowSettings.js +34 -6
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/lazy-helper.d.ts +14 -0
- package/lib/lazy-helper.js +71 -0
- package/lib/locale/en-US.json +1 -0
- package/lib/locale/index.d.ts +2 -0
- package/lib/locale/zh-CN.json +1 -0
- package/lib/models/DisplayItemModel.d.ts +1 -1
- package/lib/models/EditableItemModel.d.ts +1 -1
- package/lib/models/FilterableItemModel.d.ts +1 -1
- package/lib/models/flowModel.d.ts +13 -10
- package/lib/models/flowModel.js +126 -34
- package/lib/provider.js +38 -23
- package/lib/reactive/observer.js +46 -16
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +4 -3
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +4 -15
- package/lib/runjs-context/contexts/JSColumnRunJSContext.js +5 -2
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +5 -8
- package/lib/runjs-context/contexts/JSFieldRunJSContext.js +4 -3
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +4 -3
- package/lib/runjs-context/contexts/base.js +464 -29
- package/lib/runjs-context/contexts/elementDoc.d.ts +11 -0
- package/lib/runjs-context/contexts/elementDoc.js +152 -0
- package/lib/runjs-context/setup.js +1 -0
- package/lib/runjs-context/snippets/index.js +13 -2
- package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.js +50 -0
- package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.js +54 -0
- package/lib/types.d.ts +50 -2
- package/lib/types.js +1 -0
- package/lib/utils/createCollectionContextMeta.js +6 -2
- package/lib/utils/index.d.ts +3 -2
- package/lib/utils/index.js +7 -0
- package/lib/utils/loadedPageCache.d.ts +24 -0
- package/lib/utils/loadedPageCache.js +139 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +5 -1
- package/lib/utils/parsePathnameToViewParams.js +28 -4
- package/lib/utils/randomId.d.ts +39 -0
- package/lib/utils/randomId.js +45 -0
- package/lib/utils/runjsTemplateCompat.js +1 -1
- package/lib/utils/runjsValue.js +41 -11
- package/lib/utils/schema-utils.d.ts +7 -1
- package/lib/utils/schema-utils.js +19 -0
- package/lib/views/FlowView.d.ts +7 -1
- package/lib/views/FlowView.js +11 -1
- package/lib/views/PageComponent.js +8 -6
- package/lib/views/ViewNavigation.d.ts +12 -2
- package/lib/views/ViewNavigation.js +28 -9
- package/lib/views/createViewMeta.js +114 -50
- package/lib/views/inheritLayoutContext.d.ts +10 -0
- package/lib/views/inheritLayoutContext.js +50 -0
- package/lib/views/runViewBeforeClose.d.ts +10 -0
- package/lib/views/runViewBeforeClose.js +45 -0
- package/lib/views/useDialog.d.ts +2 -1
- package/lib/views/useDialog.js +12 -3
- package/lib/views/useDrawer.d.ts +2 -1
- package/lib/views/useDrawer.js +12 -3
- package/lib/views/usePage.d.ts +5 -11
- package/lib/views/usePage.js +304 -144
- package/package.json +5 -4
- package/src/FlowContextProvider.tsx +9 -1
- package/src/__tests__/createViewMeta.popup.test.ts +115 -1
- package/src/__tests__/flow-engine.test.ts +166 -0
- package/src/__tests__/flowContext.test.ts +105 -1
- package/src/__tests__/flowEngine.modelLoaders.test.ts +245 -0
- package/src/__tests__/flowEngine.moveModel.test.ts +81 -1
- package/src/__tests__/flowEngine.removeModel.test.ts +47 -3
- package/src/__tests__/flowSettings.test.ts +94 -15
- package/src/__tests__/objectVariable.test.ts +24 -0
- package/src/__tests__/provider.test.tsx +24 -2
- package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
- package/src/__tests__/runjsContext.test.ts +21 -0
- package/src/__tests__/runjsContextImplementations.test.ts +9 -2
- package/src/__tests__/runjsContextRuntime.test.ts +2 -0
- package/src/__tests__/runjsLocales.test.ts +6 -5
- package/src/__tests__/runjsSnippets.test.ts +21 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +136 -3
- package/src/components/FieldModelRenderer.tsx +2 -1
- package/src/components/FlowModelRenderer.tsx +18 -6
- package/src/components/FormItem.tsx +7 -1
- package/src/components/MobilePopup.tsx +4 -2
- package/src/components/__tests__/FlowModelRenderer.test.tsx +65 -2
- package/src/components/__tests__/FormItem.test.tsx +25 -0
- package/src/components/__tests__/dnd.test.ts +44 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +20 -10
- package/src/components/__tests__/gridDragPlanner.test.ts +472 -5
- package/src/components/dnd/__tests__/DndProvider.test.tsx +98 -0
- package/src/components/dnd/gridDragPlanner.ts +750 -17
- package/src/components/dnd/index.tsx +305 -28
- package/src/components/settings/wrappers/component/SelectWithTitle.tsx +21 -9
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +178 -48
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +487 -440
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +344 -8
- package/src/components/settings/wrappers/contextual/__tests__/FlowsFloatContextMenu.test.tsx +778 -0
- package/src/components/settings/wrappers/contextual/useFloatToolbarPortal.ts +360 -0
- package/src/components/settings/wrappers/contextual/useFloatToolbarVisibility.ts +361 -0
- package/src/components/subModel/AddSubModelButton.tsx +16 -2
- package/src/components/subModel/LazyDropdown.tsx +341 -56
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +524 -38
- package/src/components/subModel/__tests__/utils.test.ts +24 -0
- package/src/components/subModel/index.ts +1 -0
- package/src/components/subModel/utils.ts +13 -2
- package/src/components/variables/VariableHybridInput.tsx +531 -0
- package/src/components/variables/index.ts +2 -0
- package/src/data-source/__tests__/collection.test.ts +41 -2
- package/src/data-source/__tests__/index.test.ts +69 -2
- package/src/data-source/index.ts +332 -8
- package/src/executor/FlowExecutor.ts +6 -3
- package/src/executor/__tests__/flowExecutor.test.ts +57 -0
- package/src/flow-registry/DetachedFlowRegistry.ts +46 -0
- package/src/flow-registry/__tests__/detachedFlowRegistry.test.ts +47 -0
- package/src/flow-registry/index.ts +1 -0
- package/src/flowContext.ts +85 -6
- package/src/flowEngine.ts +484 -45
- package/src/flowI18n.ts +2 -1
- package/src/flowSettings.ts +40 -6
- package/src/index.ts +2 -0
- package/src/lazy-helper.tsx +57 -0
- package/src/locale/en-US.json +1 -0
- package/src/locale/zh-CN.json +1 -0
- package/src/models/DisplayItemModel.tsx +1 -1
- package/src/models/EditableItemModel.tsx +1 -1
- package/src/models/FilterableItemModel.tsx +1 -1
- package/src/models/__tests__/flowEngine.resolveUse.test.ts +0 -15
- package/src/models/__tests__/flowModel.test.ts +65 -37
- package/src/models/flowModel.tsx +184 -65
- package/src/provider.tsx +41 -25
- package/src/reactive/__tests__/observer.test.tsx +82 -0
- package/src/reactive/observer.tsx +87 -25
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +4 -3
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +4 -15
- package/src/runjs-context/contexts/JSColumnRunJSContext.ts +4 -2
- package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +5 -9
- package/src/runjs-context/contexts/JSFieldRunJSContext.ts +4 -3
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +4 -3
- package/src/runjs-context/contexts/base.ts +467 -31
- package/src/runjs-context/contexts/elementDoc.ts +130 -0
- package/src/runjs-context/setup.ts +1 -0
- package/src/runjs-context/snippets/index.ts +12 -1
- package/src/runjs-context/snippets/scene/detail/set-field-style.snippet.ts +30 -0
- package/src/runjs-context/snippets/scene/table/set-cell-style.snippet.ts +34 -0
- package/src/types.ts +62 -0
- package/src/utils/__tests__/createCollectionContextMeta.test.ts +48 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +21 -0
- package/src/utils/__tests__/runjsValue.test.ts +11 -0
- package/src/utils/__tests__/utils.test.ts +62 -0
- package/src/utils/createCollectionContextMeta.ts +6 -2
- package/src/utils/index.ts +5 -1
- package/src/utils/loadedPageCache.ts +147 -0
- package/src/utils/parsePathnameToViewParams.ts +45 -5
- package/src/utils/randomId.ts +48 -0
- package/src/utils/runjsTemplateCompat.ts +1 -1
- package/src/utils/runjsValue.ts +50 -11
- package/src/utils/schema-utils.ts +30 -1
- package/src/views/FlowView.tsx +22 -2
- package/src/views/PageComponent.tsx +7 -4
- package/src/views/ViewNavigation.ts +46 -9
- package/src/views/__tests__/FlowView.usePage.test.tsx +243 -3
- package/src/views/__tests__/ViewNavigation.test.ts +52 -0
- package/src/views/__tests__/inheritLayoutContext.test.ts +53 -0
- package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +12 -12
- package/src/views/createViewMeta.ts +106 -34
- package/src/views/inheritLayoutContext.ts +26 -0
- package/src/views/runViewBeforeClose.ts +19 -0
- package/src/views/useDialog.tsx +13 -3
- package/src/views/useDrawer.tsx +13 -3
- package/src/views/usePage.tsx +367 -180
|
@@ -31,6 +31,7 @@ __export(JSItemRunJSContext_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(JSItemRunJSContext_exports);
|
|
33
33
|
var import_flowContext = require("../../flowContext");
|
|
34
|
+
var import_elementDoc = require("./elementDoc");
|
|
34
35
|
const _JSItemRunJSContext = class _JSItemRunJSContext extends import_flowContext.FlowRunJSContext {
|
|
35
36
|
};
|
|
36
37
|
__name(_JSItemRunJSContext, "JSItemRunJSContext");
|
|
@@ -38,8 +39,8 @@ let JSItemRunJSContext = _JSItemRunJSContext;
|
|
|
38
39
|
JSItemRunJSContext.define({
|
|
39
40
|
label: "JSItem RunJS context",
|
|
40
41
|
properties: {
|
|
41
|
-
element: `ElementProxy instance providing a safe DOM container for form item rendering.
|
|
42
|
-
Supports innerHTML, append, and other DOM manipulation methods
|
|
42
|
+
element: (0, import_elementDoc.createElementPropertyDoc)(`ElementProxy instance providing a safe DOM container for form item rendering.
|
|
43
|
+
Supports innerHTML, append, and other DOM manipulation methods.`),
|
|
43
44
|
resource: `Current resource instance (read-only).
|
|
44
45
|
Provides access to the data resource associated with the current form context.`,
|
|
45
46
|
record: `Current record data object (read-only).
|
|
@@ -59,7 +60,7 @@ JSItemRunJSContext.define(
|
|
|
59
60
|
{
|
|
60
61
|
label: "JS \u8868\u5355\u9879 RunJS \u4E0A\u4E0B\u6587",
|
|
61
62
|
properties: {
|
|
62
|
-
element: "ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C",
|
|
63
|
+
element: (0, import_elementDoc.createZhCNElementPropertyDoc)("ElementProxy\uFF0C\u8868\u5355\u9879\u6E32\u67D3\u5BB9\u5668\uFF0C\u652F\u6301 innerHTML/append \u7B49 DOM \u64CD\u4F5C"),
|
|
63
64
|
resource: "\u5F53\u524D\u8D44\u6E90\uFF08\u53EA\u8BFB\uFF09",
|
|
64
65
|
record: "\u5F53\u524D\u8BB0\u5F55\uFF08\u53EA\u8BFB\uFF09",
|
|
65
66
|
formValues: {
|
|
@@ -35,7 +35,42 @@ function defineBaseContextMeta() {
|
|
|
35
35
|
import_flowContext.FlowRunJSContext.define({
|
|
36
36
|
label: "RunJS base",
|
|
37
37
|
properties: {
|
|
38
|
-
logger:
|
|
38
|
+
logger: {
|
|
39
|
+
description: 'Pino logger instance for structured logging. Example: `ctx.logger.info({ foo: 1 }, "message")`',
|
|
40
|
+
detail: "Logger",
|
|
41
|
+
properties: {
|
|
42
|
+
info: {
|
|
43
|
+
type: "function",
|
|
44
|
+
description: "Write an info-level log.",
|
|
45
|
+
detail: "(...args: any[]) => void",
|
|
46
|
+
completion: { insertText: `ctx.logger.info({ foo: 1 }, 'message')` }
|
|
47
|
+
},
|
|
48
|
+
warn: {
|
|
49
|
+
type: "function",
|
|
50
|
+
description: "Write a warn-level log.",
|
|
51
|
+
detail: "(...args: any[]) => void",
|
|
52
|
+
completion: { insertText: `ctx.logger.warn({ foo: 1 }, 'message')` }
|
|
53
|
+
},
|
|
54
|
+
error: {
|
|
55
|
+
type: "function",
|
|
56
|
+
description: "Write an error-level log.",
|
|
57
|
+
detail: "(...args: any[]) => void",
|
|
58
|
+
completion: { insertText: `ctx.logger.error({ err }, 'message')` }
|
|
59
|
+
},
|
|
60
|
+
debug: {
|
|
61
|
+
type: "function",
|
|
62
|
+
description: "Write a debug-level log.",
|
|
63
|
+
detail: "(...args: any[]) => void",
|
|
64
|
+
completion: { insertText: `ctx.logger.debug({ foo: 1 }, 'message')` }
|
|
65
|
+
},
|
|
66
|
+
child: {
|
|
67
|
+
type: "function",
|
|
68
|
+
description: "Create a child logger with bindings.",
|
|
69
|
+
detail: "(bindings: object) => Logger",
|
|
70
|
+
completion: { insertText: `ctx.logger.child({ module: 'runjs' })` }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
39
74
|
message: {
|
|
40
75
|
description: "Ant Design global message API for displaying temporary messages.",
|
|
41
76
|
detail: "MessageInstance",
|
|
@@ -260,12 +295,18 @@ function defineBaseContextMeta() {
|
|
|
260
295
|
popover: {
|
|
261
296
|
description: "Open a popover view. Parameters: (props: PopoverProps) => any",
|
|
262
297
|
detail: "(props) => any",
|
|
263
|
-
completion: {
|
|
298
|
+
completion: {
|
|
299
|
+
insertText: "await ctx.viewer.popover({ target: ctx.element?.__el, content: <div /> })",
|
|
300
|
+
requires: ["element"]
|
|
301
|
+
}
|
|
264
302
|
},
|
|
265
303
|
embed: {
|
|
266
304
|
description: "Open an embed view. Parameters: (props: ViewProps & TargetProps) => any",
|
|
267
305
|
detail: "(props) => any",
|
|
268
|
-
completion: {
|
|
306
|
+
completion: {
|
|
307
|
+
insertText: "await ctx.viewer.embed({ target: ctx.element?.__el, content: <div /> })",
|
|
308
|
+
requires: ["element"]
|
|
309
|
+
}
|
|
269
310
|
}
|
|
270
311
|
}
|
|
271
312
|
},
|
|
@@ -310,16 +351,165 @@ function defineBaseContextMeta() {
|
|
|
310
351
|
language: "Current active language code."
|
|
311
352
|
}
|
|
312
353
|
},
|
|
354
|
+
sql: {
|
|
355
|
+
description: "SQL helper (FlowSQLRepository).",
|
|
356
|
+
detail: "FlowSQLRepository",
|
|
357
|
+
properties: {
|
|
358
|
+
run: {
|
|
359
|
+
type: "function",
|
|
360
|
+
description: "Run ad-hoc SQL with optional bind/result options.",
|
|
361
|
+
detail: "(sql: string, options?: SQLRunOptions) => Promise<any>",
|
|
362
|
+
completion: { insertText: `await ctx.sql.run('SELECT 1', { type: 'selectRows' })` }
|
|
363
|
+
},
|
|
364
|
+
save: {
|
|
365
|
+
type: "function",
|
|
366
|
+
description: "Save a SQL template.",
|
|
367
|
+
detail: "(data: { uid: string; sql: string; dataSourceKey?: string }) => Promise<void>",
|
|
368
|
+
completion: { insertText: `await ctx.sql.save({ uid: 'sql-uid', sql: 'SELECT 1' })` }
|
|
369
|
+
},
|
|
370
|
+
runById: {
|
|
371
|
+
type: "function",
|
|
372
|
+
description: "Run a saved SQL template by uid.",
|
|
373
|
+
detail: "(uid: string, options?: SQLRunOptions) => Promise<any>",
|
|
374
|
+
completion: { insertText: `await ctx.sql.runById('sql-uid', { type: 'selectRows' })` }
|
|
375
|
+
},
|
|
376
|
+
destroy: {
|
|
377
|
+
type: "function",
|
|
378
|
+
description: "Delete a saved SQL template by uid.",
|
|
379
|
+
detail: "(uid: string) => Promise<void>",
|
|
380
|
+
completion: { insertText: `await ctx.sql.destroy('sql-uid')` }
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
},
|
|
313
384
|
libs: {
|
|
314
385
|
properties: {
|
|
315
|
-
React:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
386
|
+
React: {
|
|
387
|
+
description: "React namespace (same as ctx.React).",
|
|
388
|
+
properties: {
|
|
389
|
+
createElement: {
|
|
390
|
+
type: "function",
|
|
391
|
+
description: "Create a React element.",
|
|
392
|
+
detail: "React.createElement",
|
|
393
|
+
completion: { insertText: `ctx.libs.React.createElement('div', null, 'Hello')` }
|
|
394
|
+
},
|
|
395
|
+
useState: {
|
|
396
|
+
type: "function",
|
|
397
|
+
description: "React state hook.",
|
|
398
|
+
detail: "React.useState",
|
|
399
|
+
completion: { insertText: "ctx.libs.React.useState(initialValue)" }
|
|
400
|
+
},
|
|
401
|
+
useEffect: {
|
|
402
|
+
type: "function",
|
|
403
|
+
description: "React effect hook.",
|
|
404
|
+
detail: "React.useEffect",
|
|
405
|
+
completion: { insertText: "ctx.libs.React.useEffect(() => {}, [])" }
|
|
406
|
+
},
|
|
407
|
+
useMemo: {
|
|
408
|
+
type: "function",
|
|
409
|
+
description: "React memo hook.",
|
|
410
|
+
detail: "React.useMemo",
|
|
411
|
+
completion: { insertText: "ctx.libs.React.useMemo(() => value, [])" }
|
|
412
|
+
},
|
|
413
|
+
useCallback: {
|
|
414
|
+
type: "function",
|
|
415
|
+
description: "React callback hook.",
|
|
416
|
+
detail: "React.useCallback",
|
|
417
|
+
completion: { insertText: "ctx.libs.React.useCallback(() => {}, [])" }
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
ReactDOM: {
|
|
422
|
+
description: "ReactDOM client API (same as ctx.ReactDOM).",
|
|
423
|
+
properties: {
|
|
424
|
+
createRoot: {
|
|
425
|
+
type: "function",
|
|
426
|
+
description: "Create a React root.",
|
|
427
|
+
detail: "ReactDOM.createRoot",
|
|
428
|
+
completion: { insertText: "ctx.libs.ReactDOM.createRoot(ctx.element.__el)", requires: ["element"] }
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
antd: {
|
|
433
|
+
description: "Ant Design component library (same as ctx.antd).",
|
|
434
|
+
properties: {
|
|
435
|
+
Button: "Ant Design Button component.",
|
|
436
|
+
Table: "Ant Design Table component.",
|
|
437
|
+
Form: "Ant Design Form component.",
|
|
438
|
+
Input: "Ant Design Input component.",
|
|
439
|
+
Select: "Ant Design Select component.",
|
|
440
|
+
Modal: "Ant Design Modal API/component."
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
dayjs: {
|
|
444
|
+
type: "function",
|
|
445
|
+
description: "dayjs date-time utility library.",
|
|
446
|
+
detail: "dayjs",
|
|
447
|
+
completion: { insertText: "ctx.libs.dayjs()" }
|
|
448
|
+
},
|
|
319
449
|
antdIcons: "Ant Design icons library. Example: `ctx.libs.antdIcons.PlusOutlined`.",
|
|
320
|
-
lodash:
|
|
321
|
-
|
|
322
|
-
|
|
450
|
+
lodash: {
|
|
451
|
+
description: 'Lodash utility library. Example: `ctx.libs.lodash.get(obj, "a.b")`.',
|
|
452
|
+
properties: {
|
|
453
|
+
get: {
|
|
454
|
+
type: "function",
|
|
455
|
+
description: "Read a nested value by path.",
|
|
456
|
+
detail: "lodash.get",
|
|
457
|
+
completion: { insertText: `ctx.libs.lodash.get(obj, 'a.b')` }
|
|
458
|
+
},
|
|
459
|
+
set: {
|
|
460
|
+
type: "function",
|
|
461
|
+
description: "Set a nested value by path.",
|
|
462
|
+
detail: "lodash.set",
|
|
463
|
+
completion: { insertText: `ctx.libs.lodash.set(obj, 'a.b', value)` }
|
|
464
|
+
},
|
|
465
|
+
debounce: {
|
|
466
|
+
type: "function",
|
|
467
|
+
description: "Create a debounced function.",
|
|
468
|
+
detail: "lodash.debounce",
|
|
469
|
+
completion: { insertText: "ctx.libs.lodash.debounce(() => {}, 300)" }
|
|
470
|
+
},
|
|
471
|
+
cloneDeep: {
|
|
472
|
+
type: "function",
|
|
473
|
+
description: "Deep clone a value.",
|
|
474
|
+
detail: "lodash.cloneDeep",
|
|
475
|
+
completion: { insertText: "ctx.libs.lodash.cloneDeep(value)" }
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
formula: {
|
|
480
|
+
description: "Formula.js library (spreadsheet-like functions). Example: `ctx.libs.formula.SUM(1, 2, 3)`.",
|
|
481
|
+
properties: {
|
|
482
|
+
SUM: {
|
|
483
|
+
type: "function",
|
|
484
|
+
description: "Sum values.",
|
|
485
|
+
detail: "formula.SUM",
|
|
486
|
+
completion: { insertText: "ctx.libs.formula.SUM(1, 2, 3)" }
|
|
487
|
+
},
|
|
488
|
+
AVERAGE: {
|
|
489
|
+
type: "function",
|
|
490
|
+
description: "Average values.",
|
|
491
|
+
detail: "formula.AVERAGE",
|
|
492
|
+
completion: { insertText: "ctx.libs.formula.AVERAGE(1, 2, 3)" }
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
math: {
|
|
497
|
+
description: 'mathjs library. Example: `ctx.libs.math.evaluate("2 + 3")`.',
|
|
498
|
+
properties: {
|
|
499
|
+
evaluate: {
|
|
500
|
+
type: "function",
|
|
501
|
+
description: "Evaluate a math expression.",
|
|
502
|
+
detail: "math.evaluate",
|
|
503
|
+
completion: { insertText: `ctx.libs.math.evaluate('2 + 3')` }
|
|
504
|
+
},
|
|
505
|
+
round: {
|
|
506
|
+
type: "function",
|
|
507
|
+
description: "Round a number.",
|
|
508
|
+
detail: "math.round",
|
|
509
|
+
completion: { insertText: "ctx.libs.math.round(value, 2)" }
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
323
513
|
}
|
|
324
514
|
}
|
|
325
515
|
},
|
|
@@ -348,7 +538,12 @@ function defineBaseContextMeta() {
|
|
|
348
538
|
returns: { type: "FlowModel | undefined" },
|
|
349
539
|
examples: ["const model = ctx.getModel('block-uid-xxx');"]
|
|
350
540
|
},
|
|
351
|
-
t:
|
|
541
|
+
t: {
|
|
542
|
+
description: "Internationalization function for translating text. Parameters: (key: string, variables?: object) => string.",
|
|
543
|
+
detail: "(key: string, variables?: object) => string",
|
|
544
|
+
completion: { insertText: `ctx.t('Hello')` },
|
|
545
|
+
examples: [`ctx.t("Hello {{name}}", { name: "World" })`]
|
|
546
|
+
},
|
|
352
547
|
initResource: {
|
|
353
548
|
description: 'Initialize ctx.resource as a FlowResource instance by class name. Common values: "MultiRecordResource", "SingleRecordResource", "SQLResource".',
|
|
354
549
|
detail: "(resourceType: ResourceType) => void",
|
|
@@ -365,11 +560,34 @@ function defineBaseContextMeta() {
|
|
|
365
560
|
description: 'Render into container. Accepts ReactElement, DOM Node/Fragment, or HTML string. Parameters: (vnode: ReactElement | Node | DocumentFragment | string, container?: HTMLElement|ElementProxy) => Root|null. Example: `ctx.render(<div>Hello</div>)` or `ctx.render("<b>hi</b>")`',
|
|
366
561
|
detail: "ReactDOM Root",
|
|
367
562
|
completion: {
|
|
368
|
-
insertText: `ctx.render(<div />)
|
|
563
|
+
insertText: `ctx.render(<div />)`,
|
|
564
|
+
requires: ["element"]
|
|
369
565
|
}
|
|
370
566
|
},
|
|
371
|
-
requireAsync:
|
|
372
|
-
|
|
567
|
+
requireAsync: {
|
|
568
|
+
description: 'Load UMD/AMD/global scripts or CSS asynchronously from URL. Accepts shorthand like "echarts@5/dist/echarts.min.js" (resolved via ESM CDN with ?raw) or full URLs, and returns a Promise of the loaded library.',
|
|
569
|
+
detail: "(url: string) => Promise<any>",
|
|
570
|
+
completion: { insertText: `const lib = await ctx.requireAsync('https://cdn.example.com/lib.umd.js')` }
|
|
571
|
+
},
|
|
572
|
+
importAsync: {
|
|
573
|
+
description: 'Dynamically import ESM modules or CSS by URL. Accepts shorthand like "vue@3.4.0" or "dayjs@1/plugin/relativeTime.js" (resolved via configured ESM CDN) or full URLs, and returns a Promise of the module namespace.',
|
|
574
|
+
detail: "(url: string) => Promise<any>",
|
|
575
|
+
completion: { insertText: `const mod = await ctx.importAsync('lodash-es')` }
|
|
576
|
+
},
|
|
577
|
+
resolveJsonTemplate: {
|
|
578
|
+
description: "Resolve a JSON template containing {{ }} variable expressions.",
|
|
579
|
+
detail: "(template: any) => Promise<any>",
|
|
580
|
+
params: [
|
|
581
|
+
{
|
|
582
|
+
name: "template",
|
|
583
|
+
type: "any",
|
|
584
|
+
description: "JSON-compatible value containing {{ ctx.* }} expressions."
|
|
585
|
+
}
|
|
586
|
+
],
|
|
587
|
+
returns: { type: "Promise<any>" },
|
|
588
|
+
completion: { insertText: `await ctx.resolveJsonTemplate({ value: '{{ctx.record.id}}' })` },
|
|
589
|
+
examples: ["const data = await ctx.resolveJsonTemplate({ id: '{{ctx.record.id}}' });"]
|
|
590
|
+
},
|
|
373
591
|
getVar: {
|
|
374
592
|
description: 'Resolve a ctx expression value by path string (expression starts with "ctx.").',
|
|
375
593
|
detail: "(path: string) => Promise<any>",
|
|
@@ -455,7 +673,42 @@ function defineBaseContextMeta() {
|
|
|
455
673
|
{
|
|
456
674
|
label: "RunJS \u57FA\u7840",
|
|
457
675
|
properties: {
|
|
458
|
-
logger:
|
|
676
|
+
logger: {
|
|
677
|
+
description: 'Pino \u65E5\u5FD7\u5B9E\u4F8B\uFF08\u7ED3\u6784\u5316\u65E5\u5FD7\uFF09\u3002\u793A\u4F8B\uFF1A`ctx.logger.info({ foo: 1 }, "message")`',
|
|
678
|
+
detail: "Logger",
|
|
679
|
+
properties: {
|
|
680
|
+
info: {
|
|
681
|
+
type: "function",
|
|
682
|
+
description: "\u5199\u5165 info \u7EA7\u522B\u65E5\u5FD7\u3002",
|
|
683
|
+
detail: "(...args: any[]) => void",
|
|
684
|
+
completion: { insertText: `ctx.logger.info({ foo: 1 }, 'message')` }
|
|
685
|
+
},
|
|
686
|
+
warn: {
|
|
687
|
+
type: "function",
|
|
688
|
+
description: "\u5199\u5165 warn \u7EA7\u522B\u65E5\u5FD7\u3002",
|
|
689
|
+
detail: "(...args: any[]) => void",
|
|
690
|
+
completion: { insertText: `ctx.logger.warn({ foo: 1 }, 'message')` }
|
|
691
|
+
},
|
|
692
|
+
error: {
|
|
693
|
+
type: "function",
|
|
694
|
+
description: "\u5199\u5165 error \u7EA7\u522B\u65E5\u5FD7\u3002",
|
|
695
|
+
detail: "(...args: any[]) => void",
|
|
696
|
+
completion: { insertText: `ctx.logger.error({ err }, 'message')` }
|
|
697
|
+
},
|
|
698
|
+
debug: {
|
|
699
|
+
type: "function",
|
|
700
|
+
description: "\u5199\u5165 debug \u7EA7\u522B\u65E5\u5FD7\u3002",
|
|
701
|
+
detail: "(...args: any[]) => void",
|
|
702
|
+
completion: { insertText: `ctx.logger.debug({ foo: 1 }, 'message')` }
|
|
703
|
+
},
|
|
704
|
+
child: {
|
|
705
|
+
type: "function",
|
|
706
|
+
description: "\u521B\u5EFA\u5E26\u7ED1\u5B9A\u5B57\u6BB5\u7684\u5B50 logger\u3002",
|
|
707
|
+
detail: "(bindings: object) => Logger",
|
|
708
|
+
completion: { insertText: `ctx.logger.child({ module: 'runjs' })` }
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
},
|
|
459
712
|
message: {
|
|
460
713
|
description: "Ant Design \u5168\u5C40\u6D88\u606F API\uFF0C\u7528\u4E8E\u663E\u793A\u4E34\u65F6\u63D0\u793A\u3002",
|
|
461
714
|
detail: "MessageInstance",
|
|
@@ -677,12 +930,18 @@ function defineBaseContextMeta() {
|
|
|
677
930
|
popover: {
|
|
678
931
|
description: "\u6253\u5F00\u6C14\u6CE1\u5361\u7247\u89C6\u56FE\u3002\u53C2\u6570\uFF1A(props: PopoverProps) => any",
|
|
679
932
|
detail: "(props) => any",
|
|
680
|
-
completion: {
|
|
933
|
+
completion: {
|
|
934
|
+
insertText: "await ctx.viewer.popover({ target: ctx.element?.__el, content: <div /> })",
|
|
935
|
+
requires: ["element"]
|
|
936
|
+
}
|
|
681
937
|
},
|
|
682
938
|
embed: {
|
|
683
939
|
description: "\u6253\u5F00\u5185\u5D4C\u89C6\u56FE\u3002\u53C2\u6570\uFF1A(props: ViewProps & TargetProps) => any",
|
|
684
940
|
detail: "(props) => any",
|
|
685
|
-
completion: {
|
|
941
|
+
completion: {
|
|
942
|
+
insertText: "await ctx.viewer.embed({ target: ctx.element?.__el, content: <div /> })",
|
|
943
|
+
requires: ["element"]
|
|
944
|
+
}
|
|
686
945
|
}
|
|
687
946
|
}
|
|
688
947
|
},
|
|
@@ -719,6 +978,36 @@ function defineBaseContextMeta() {
|
|
|
719
978
|
language: "\u5F53\u524D\u6FC0\u6D3B\u7684\u8BED\u8A00\u4EE3\u7801"
|
|
720
979
|
}
|
|
721
980
|
},
|
|
981
|
+
sql: {
|
|
982
|
+
description: "SQL \u6267\u884C\u52A9\u624B\uFF08FlowSQLRepository\uFF09\u3002",
|
|
983
|
+
detail: "FlowSQLRepository",
|
|
984
|
+
properties: {
|
|
985
|
+
run: {
|
|
986
|
+
type: "function",
|
|
987
|
+
description: "\u6267\u884C\u4E34\u65F6 SQL\uFF0C\u53EF\u4F20\u7ED1\u5B9A\u53C2\u6570\u4E0E\u7ED3\u679C\u7C7B\u578B\u3002",
|
|
988
|
+
detail: "(sql: string, options?: SQLRunOptions) => Promise<any>",
|
|
989
|
+
completion: { insertText: `await ctx.sql.run('SELECT 1', { type: 'selectRows' })` }
|
|
990
|
+
},
|
|
991
|
+
save: {
|
|
992
|
+
type: "function",
|
|
993
|
+
description: "\u4FDD\u5B58 SQL \u6A21\u677F\u3002",
|
|
994
|
+
detail: "(data: { uid: string; sql: string; dataSourceKey?: string }) => Promise<void>",
|
|
995
|
+
completion: { insertText: `await ctx.sql.save({ uid: 'sql-uid', sql: 'SELECT 1' })` }
|
|
996
|
+
},
|
|
997
|
+
runById: {
|
|
998
|
+
type: "function",
|
|
999
|
+
description: "\u6309 uid \u6267\u884C\u5DF2\u4FDD\u5B58 SQL \u6A21\u677F\u3002",
|
|
1000
|
+
detail: "(uid: string, options?: SQLRunOptions) => Promise<any>",
|
|
1001
|
+
completion: { insertText: `await ctx.sql.runById('sql-uid', { type: 'selectRows' })` }
|
|
1002
|
+
},
|
|
1003
|
+
destroy: {
|
|
1004
|
+
type: "function",
|
|
1005
|
+
description: "\u6309 uid \u5220\u9664\u5DF2\u4FDD\u5B58 SQL \u6A21\u677F\u3002",
|
|
1006
|
+
detail: "(uid: string) => Promise<void>",
|
|
1007
|
+
completion: { insertText: `await ctx.sql.destroy('sql-uid')` }
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
},
|
|
722
1011
|
dayjs: {
|
|
723
1012
|
type: "function",
|
|
724
1013
|
description: "dayjs \u65E5\u671F\u65F6\u95F4\u5DE5\u5177\u5E93\uFF08\u53EF\u8C03\u7528\uFF09\u3002",
|
|
@@ -733,14 +1022,133 @@ function defineBaseContextMeta() {
|
|
|
733
1022
|
description: "\u7B2C\u4E09\u65B9/\u901A\u7528\u5E93\u7684\u7EDF\u4E00\u547D\u540D\u7A7A\u95F4\uFF0C\u5305\u542B React\u3001ReactDOM\u3001Ant Design\u3001dayjs\u3001icons \u7B49\uFF0C\u5E76\u53EF\u6269\u5C55\u66F4\u591A\u5DE5\u5177\u5E93\uFF08\u5982 lodash\u3001formula\u3001math\uFF09\u3002\u540E\u7EED\u65B0\u589E\u5E93\u4F1A\u4F18\u5148\u6302\u5728\u6B64\u5904\u3002",
|
|
734
1023
|
detail: "\u901A\u7528\u5E93\u547D\u540D\u7A7A\u95F4",
|
|
735
1024
|
properties: {
|
|
736
|
-
React:
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
1025
|
+
React: {
|
|
1026
|
+
description: "React \u547D\u540D\u7A7A\u95F4\uFF08\u7B49\u4EF7\u4E8E ctx.React\uFF09\u3002",
|
|
1027
|
+
properties: {
|
|
1028
|
+
createElement: {
|
|
1029
|
+
type: "function",
|
|
1030
|
+
description: "\u521B\u5EFA React \u5143\u7D20\u3002",
|
|
1031
|
+
detail: "React.createElement",
|
|
1032
|
+
completion: { insertText: `ctx.libs.React.createElement('div', null, 'Hello')` }
|
|
1033
|
+
},
|
|
1034
|
+
useState: {
|
|
1035
|
+
type: "function",
|
|
1036
|
+
description: "React state hook\u3002",
|
|
1037
|
+
detail: "React.useState",
|
|
1038
|
+
completion: { insertText: "ctx.libs.React.useState(initialValue)" }
|
|
1039
|
+
},
|
|
1040
|
+
useEffect: {
|
|
1041
|
+
type: "function",
|
|
1042
|
+
description: "React effect hook\u3002",
|
|
1043
|
+
detail: "React.useEffect",
|
|
1044
|
+
completion: { insertText: "ctx.libs.React.useEffect(() => {}, [])" }
|
|
1045
|
+
},
|
|
1046
|
+
useMemo: {
|
|
1047
|
+
type: "function",
|
|
1048
|
+
description: "React memo hook\u3002",
|
|
1049
|
+
detail: "React.useMemo",
|
|
1050
|
+
completion: { insertText: "ctx.libs.React.useMemo(() => value, [])" }
|
|
1051
|
+
},
|
|
1052
|
+
useCallback: {
|
|
1053
|
+
type: "function",
|
|
1054
|
+
description: "React callback hook\u3002",
|
|
1055
|
+
detail: "React.useCallback",
|
|
1056
|
+
completion: { insertText: "ctx.libs.React.useCallback(() => {}, [])" }
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
ReactDOM: {
|
|
1061
|
+
description: "ReactDOM \u5BA2\u6237\u7AEF API\uFF08\u7B49\u4EF7\u4E8E ctx.ReactDOM\uFF09\u3002",
|
|
1062
|
+
properties: {
|
|
1063
|
+
createRoot: {
|
|
1064
|
+
type: "function",
|
|
1065
|
+
description: "\u521B\u5EFA React \u6839\u3002",
|
|
1066
|
+
detail: "ReactDOM.createRoot",
|
|
1067
|
+
completion: { insertText: "ctx.libs.ReactDOM.createRoot(ctx.element.__el)", requires: ["element"] }
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
1071
|
+
antd: {
|
|
1072
|
+
description: "Ant Design \u7EC4\u4EF6\u5E93\uFF08\u7B49\u4EF7\u4E8E ctx.antd\uFF09\u3002",
|
|
1073
|
+
properties: {
|
|
1074
|
+
Button: "Ant Design Button \u7EC4\u4EF6\u3002",
|
|
1075
|
+
Table: "Ant Design Table \u7EC4\u4EF6\u3002",
|
|
1076
|
+
Form: "Ant Design Form \u7EC4\u4EF6\u3002",
|
|
1077
|
+
Input: "Ant Design Input \u7EC4\u4EF6\u3002",
|
|
1078
|
+
Select: "Ant Design Select \u7EC4\u4EF6\u3002",
|
|
1079
|
+
Modal: "Ant Design Modal API/\u7EC4\u4EF6\u3002"
|
|
1080
|
+
}
|
|
1081
|
+
},
|
|
1082
|
+
dayjs: {
|
|
1083
|
+
type: "function",
|
|
1084
|
+
description: "dayjs \u65E5\u671F\u65F6\u95F4\u5DE5\u5177\u5E93\u3002",
|
|
1085
|
+
detail: "dayjs",
|
|
1086
|
+
completion: { insertText: "ctx.libs.dayjs()" }
|
|
1087
|
+
},
|
|
740
1088
|
antdIcons: "Ant Design \u56FE\u6807\u5E93\u3002 \u4F8B\u5982\uFF1A`ctx.libs.antdIcons.PlusOutlined`\u3002",
|
|
741
|
-
lodash:
|
|
742
|
-
|
|
743
|
-
|
|
1089
|
+
lodash: {
|
|
1090
|
+
description: 'Lodash \u5DE5\u5177\u5E93\u3002\u793A\u4F8B\uFF1A`ctx.libs.lodash.get(obj, "a.b")`\u3002',
|
|
1091
|
+
properties: {
|
|
1092
|
+
get: {
|
|
1093
|
+
type: "function",
|
|
1094
|
+
description: "\u6309\u8DEF\u5F84\u8BFB\u53D6\u5D4C\u5957\u503C\u3002",
|
|
1095
|
+
detail: "lodash.get",
|
|
1096
|
+
completion: { insertText: `ctx.libs.lodash.get(obj, 'a.b')` }
|
|
1097
|
+
},
|
|
1098
|
+
set: {
|
|
1099
|
+
type: "function",
|
|
1100
|
+
description: "\u6309\u8DEF\u5F84\u8BBE\u7F6E\u5D4C\u5957\u503C\u3002",
|
|
1101
|
+
detail: "lodash.set",
|
|
1102
|
+
completion: { insertText: `ctx.libs.lodash.set(obj, 'a.b', value)` }
|
|
1103
|
+
},
|
|
1104
|
+
debounce: {
|
|
1105
|
+
type: "function",
|
|
1106
|
+
description: "\u521B\u5EFA\u9632\u6296\u51FD\u6570\u3002",
|
|
1107
|
+
detail: "lodash.debounce",
|
|
1108
|
+
completion: { insertText: "ctx.libs.lodash.debounce(() => {}, 300)" }
|
|
1109
|
+
},
|
|
1110
|
+
cloneDeep: {
|
|
1111
|
+
type: "function",
|
|
1112
|
+
description: "\u6DF1\u62F7\u8D1D\u503C\u3002",
|
|
1113
|
+
detail: "lodash.cloneDeep",
|
|
1114
|
+
completion: { insertText: "ctx.libs.lodash.cloneDeep(value)" }
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
formula: {
|
|
1119
|
+
description: "Formula.js \u516C\u5F0F\u5E93\uFF08\u7C7B\u8868\u683C\u51FD\u6570\uFF09\u3002\u793A\u4F8B\uFF1A`ctx.libs.formula.SUM(1, 2, 3)`\u3002",
|
|
1120
|
+
properties: {
|
|
1121
|
+
SUM: {
|
|
1122
|
+
type: "function",
|
|
1123
|
+
description: "\u6C42\u548C\u3002",
|
|
1124
|
+
detail: "formula.SUM",
|
|
1125
|
+
completion: { insertText: "ctx.libs.formula.SUM(1, 2, 3)" }
|
|
1126
|
+
},
|
|
1127
|
+
AVERAGE: {
|
|
1128
|
+
type: "function",
|
|
1129
|
+
description: "\u6C42\u5E73\u5747\u503C\u3002",
|
|
1130
|
+
detail: "formula.AVERAGE",
|
|
1131
|
+
completion: { insertText: "ctx.libs.formula.AVERAGE(1, 2, 3)" }
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
math: {
|
|
1136
|
+
description: 'mathjs \u6570\u5B66\u5E93\u3002\u793A\u4F8B\uFF1A`ctx.libs.math.evaluate("2 + 3")`\u3002',
|
|
1137
|
+
properties: {
|
|
1138
|
+
evaluate: {
|
|
1139
|
+
type: "function",
|
|
1140
|
+
description: "\u8BA1\u7B97\u6570\u5B66\u8868\u8FBE\u5F0F\u3002",
|
|
1141
|
+
detail: "math.evaluate",
|
|
1142
|
+
completion: { insertText: `ctx.libs.math.evaluate('2 + 3')` }
|
|
1143
|
+
},
|
|
1144
|
+
round: {
|
|
1145
|
+
type: "function",
|
|
1146
|
+
description: "\u56DB\u820D\u4E94\u5165\u3002",
|
|
1147
|
+
detail: "math.round",
|
|
1148
|
+
completion: { insertText: "ctx.libs.math.round(value, 2)" }
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
744
1152
|
}
|
|
745
1153
|
}
|
|
746
1154
|
},
|
|
@@ -770,7 +1178,12 @@ function defineBaseContextMeta() {
|
|
|
770
1178
|
returns: { type: "FlowModel | undefined" },
|
|
771
1179
|
examples: ["const model = ctx.getModel('block-uid-xxx');"]
|
|
772
1180
|
},
|
|
773
|
-
t:
|
|
1181
|
+
t: {
|
|
1182
|
+
description: "\u56FD\u9645\u5316\u51FD\u6570\uFF0C\u7528\u4E8E\u7FFB\u8BD1\u6587\u6848\u3002\u53C2\u6570\uFF1A(key: string, variables?: object) => string\u3002",
|
|
1183
|
+
detail: "(key: string, variables?: object) => string",
|
|
1184
|
+
completion: { insertText: `ctx.t('\u4F60\u597D')` },
|
|
1185
|
+
examples: [`ctx.t("\u4F60\u597D {{name}}", { name: "\u4E16\u754C" })`]
|
|
1186
|
+
},
|
|
774
1187
|
initResource: {
|
|
775
1188
|
description: '\u521D\u59CB\u5316\u5F53\u524D\u4E0A\u4E0B\u6587\u7684\u8D44\u6E90\uFF1A\u82E5\u5C1A\u672A\u5B58\u5728 ctx.resource\uFF0C\u5219\u6309\u8D44\u6E90\u7C7B\u540D\u521B\u5EFA\u5E76\u7ED1\u5B9A\uFF1B\u82E5\u5DF2\u5B58\u5728\u5219\u76F4\u63A5\u590D\u7528\u3002\u5E38\u7528\u503C\uFF1A"MultiRecordResource"\u3001"SingleRecordResource"\u3001"SQLResource"\u3002',
|
|
776
1189
|
detail: "(resourceType: ResourceType) => void",
|
|
@@ -787,11 +1200,20 @@ function defineBaseContextMeta() {
|
|
|
787
1200
|
description: '\u6E32\u67D3\u5230\u5BB9\u5668\u3002vnode \u652F\u6301 ReactElement\u3001DOM \u8282\u70B9/\u7247\u6BB5\u3001\u6216 HTML \u5B57\u7B26\u4E32\u3002\u53C2\u6570\uFF1A(vnode: ReactElement | Node | DocumentFragment | string, container?: HTMLElement|ElementProxy) => Root|null\u3002\u793A\u4F8B\uFF1A`ctx.render(<div />)` \u6216 `ctx.render("<b>hi</b>")`',
|
|
788
1201
|
detail: "ReactDOM Root",
|
|
789
1202
|
completion: {
|
|
790
|
-
insertText: `ctx.render(<div />)
|
|
1203
|
+
insertText: `ctx.render(<div />)`,
|
|
1204
|
+
requires: ["element"]
|
|
791
1205
|
}
|
|
792
1206
|
},
|
|
793
|
-
requireAsync:
|
|
794
|
-
|
|
1207
|
+
requireAsync: {
|
|
1208
|
+
description: '\u6309 URL \u5F02\u6B65\u52A0\u8F7D UMD/AMD \u6216\u6302\u5230\u5168\u5C40\u7684\u811A\u672C\uFF0C\u4E5F\u53EF\u52A0\u8F7D CSS\u3002\u652F\u6301\u7B80\u5199\u8DEF\u5F84\uFF08\u5982 "echarts@5/dist/echarts.min.js"\uFF0C\u4F1A\u7ECF\u7531 ESM CDN \u52A0 ?raw \u83B7\u53D6\u539F\u59CB\u6587\u4EF6\uFF09\u548C\u5B8C\u6574 URL\uFF0C\u8FD4\u56DE\u52A0\u8F7D\u540E\u7684\u5E93\u5BF9\u8C61\u6216\u6837\u5F0F\u6CE8\u5165\u7ED3\u679C\u3002',
|
|
1209
|
+
detail: "(url: string) => Promise<any>",
|
|
1210
|
+
completion: { insertText: `const lib = await ctx.requireAsync('https://cdn.example.com/lib.umd.js')` }
|
|
1211
|
+
},
|
|
1212
|
+
importAsync: {
|
|
1213
|
+
description: '\u6309 URL \u52A8\u6001\u52A0\u8F7D ESM \u6A21\u5757\u6216 CSS\u3002\u652F\u6301\u7B80\u5199\uFF08\u5982 "vue@3.4.0"\u3001"dayjs@1/plugin/relativeTime.js"\uFF0C\u4F1A\u6309\u914D\u7F6E\u62FC\u63A5 ESM CDN \u524D\u7F00\uFF09\u548C\u5B8C\u6574 URL\uFF0C\u8FD4\u56DE\u6A21\u5757\u547D\u540D\u7A7A\u95F4\u6216\u6837\u5F0F\u6CE8\u5165\u7ED3\u679C\u3002',
|
|
1214
|
+
detail: "(url: string) => Promise<any>",
|
|
1215
|
+
completion: { insertText: `const mod = await ctx.importAsync('lodash-es')` }
|
|
1216
|
+
},
|
|
795
1217
|
getVar: {
|
|
796
1218
|
description: '\u901A\u8FC7\u8868\u8FBE\u5F0F\u8DEF\u5F84\u5B57\u7B26\u4E32\u83B7\u53D6 ctx \u7684\u8FD0\u884C\u65F6\u503C\uFF08\u4EE5 "ctx." \u5F00\u5934\uFF09\u3002',
|
|
797
1219
|
detail: "(path: string) => Promise<any>",
|
|
@@ -843,7 +1265,20 @@ function defineBaseContextMeta() {
|
|
|
843
1265
|
returns: { type: "Promise<Record<string, any>>" },
|
|
844
1266
|
examples: ["const envs = await ctx.getEnvInfos();"]
|
|
845
1267
|
},
|
|
846
|
-
resolveJsonTemplate:
|
|
1268
|
+
resolveJsonTemplate: {
|
|
1269
|
+
description: "\u89E3\u6790\u542B {{ }} \u53D8\u91CF\u8868\u8FBE\u5F0F\u7684 JSON \u6A21\u677F\u3002",
|
|
1270
|
+
detail: "(template: any) => Promise<any>",
|
|
1271
|
+
params: [
|
|
1272
|
+
{
|
|
1273
|
+
name: "template",
|
|
1274
|
+
type: "any",
|
|
1275
|
+
description: "\u5305\u542B {{ ctx.* }} \u8868\u8FBE\u5F0F\u7684 JSON \u517C\u5BB9\u503C\u3002"
|
|
1276
|
+
}
|
|
1277
|
+
],
|
|
1278
|
+
returns: { type: "Promise<any>" },
|
|
1279
|
+
completion: { insertText: `await ctx.resolveJsonTemplate({ value: '{{ctx.record.id}}' })` },
|
|
1280
|
+
examples: ["const data = await ctx.resolveJsonTemplate({ id: '{{ctx.record.id}}' });"]
|
|
1281
|
+
},
|
|
847
1282
|
runAction: {
|
|
848
1283
|
description: '\u5BF9\u5F53\u524D\u8D44\u6E90\u6267\u884C\u6570\u636E\u52A8\u4F5C\u3002\u53C2\u6570\uFF1A(actionName: string, params: object) => Promise<any>\u3002\u793A\u4F8B\uFF1A`await ctx.runAction("create", { values: { name: "test" } })`',
|
|
849
1284
|
detail: "Promise<any>",
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
import type { RunJSDocPropertyDoc } from '../../flowContext';
|
|
10
|
+
export declare function createElementPropertyDoc(description?: string): RunJSDocPropertyDoc;
|
|
11
|
+
export declare function createZhCNElementPropertyDoc(description?: string): RunJSDocPropertyDoc;
|