@nocobase/flow-engine 2.0.0-alpha.9 → 2.0.0-beta.2
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/BlockScopedFlowEngine.d.ts +23 -0
- package/lib/BlockScopedFlowEngine.js +92 -0
- package/lib/FlowDefinition.d.ts +6 -4
- package/lib/JSRunner.js +3 -0
- package/lib/ViewScopedFlowEngine.js +15 -1
- package/lib/acl/Acl.d.ts +12 -12
- package/lib/acl/Acl.js +78 -30
- package/lib/components/DynamicFlowsEditor.js +2 -4
- package/lib/components/FieldModelRenderer.js +10 -8
- package/lib/components/FieldSkeleton.d.ts +10 -0
- package/lib/components/FieldSkeleton.js +64 -0
- package/lib/components/FlowContextSelector.js +19 -3
- package/lib/components/FlowModelRenderer.d.ts +2 -1
- package/lib/components/FlowModelRenderer.js +34 -12
- package/lib/components/FormItem.js +5 -1
- package/lib/components/MobilePopup.d.ts +20 -0
- package/lib/components/MobilePopup.js +102 -0
- package/lib/components/MobilePopup.style.d.ts +17 -0
- package/lib/components/MobilePopup.style.js +186 -0
- package/lib/components/common/withFlowDesignMode.d.ts +1 -1
- package/lib/components/common/withFlowDesignMode.js +5 -5
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +3 -1
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.js +71 -53
- package/lib/components/settings/wrappers/component/SelectWithTitle.d.ts +19 -0
- package/lib/components/settings/wrappers/component/SelectWithTitle.js +136 -0
- package/lib/components/settings/wrappers/component/SwitchWithTitle.d.ts +10 -0
- package/lib/components/settings/wrappers/component/SwitchWithTitle.js +110 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +221 -93
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +71 -54
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +2 -2
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +63 -23
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +11 -6
- package/lib/components/settings/wrappers/embedded/FlowSettings.js +42 -28
- package/lib/components/settings/wrappers/embedded/FlowsSettings.js +3 -3
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.js +52 -32
- package/lib/components/subModel/AddSubModelButton.d.ts +7 -0
- package/lib/components/subModel/AddSubModelButton.js +78 -8
- package/lib/components/subModel/LazyDropdown.js +14 -15
- package/lib/components/subModel/utils.d.ts +1 -1
- package/lib/components/subModel/utils.js +21 -11
- package/lib/components/variables/VariableInput.js +5 -3
- package/lib/components/variables/types.d.ts +2 -0
- package/lib/components/variables/utils.js +4 -2
- package/lib/data-source/index.d.ts +43 -4
- package/lib/data-source/index.js +104 -11
- package/lib/data-source/jioToJoiSchema.js +1 -0
- package/lib/emitter.d.ts +6 -0
- package/lib/emitter.js +12 -0
- package/lib/executor/FlowExecutor.js +48 -7
- package/lib/flow-registry/GlobalFlowRegistry.d.ts +1 -0
- package/lib/flow-registry/GlobalFlowRegistry.js +3 -0
- package/lib/flow-registry/InstanceFlowRegistry.d.ts +1 -0
- package/lib/flow-registry/InstanceFlowRegistry.js +3 -0
- package/lib/flowContext.d.ts +6 -0
- package/lib/flowContext.js +111 -30
- package/lib/flowEngine.d.ts +49 -0
- package/lib/flowEngine.js +265 -10
- package/lib/flowSettings.d.ts +4 -3
- package/lib/flowSettings.js +33 -11
- package/lib/hooks/useApplyAutoFlows.d.ts +1 -0
- package/lib/hooks/useApplyAutoFlows.js +2 -2
- package/lib/index.d.ts +4 -2
- package/lib/index.js +11 -5
- package/lib/locale/de-DE.json +62 -0
- package/lib/locale/en-US.json +57 -45
- package/lib/locale/es-ES.json +62 -0
- package/lib/locale/fr-FR.json +62 -0
- package/lib/locale/hu-HU.json +62 -0
- package/lib/locale/id-ID.json +62 -0
- package/lib/locale/index.d.ts +114 -90
- package/lib/locale/it-IT.json +62 -0
- package/lib/locale/ja-JP.json +62 -0
- package/lib/locale/ko-KR.json +62 -0
- package/lib/locale/nl-NL.json +62 -0
- package/lib/locale/pt-BR.json +62 -0
- package/lib/locale/ru-RU.json +62 -0
- package/lib/locale/tr-TR.json +62 -0
- package/lib/locale/uk-UA.json +62 -0
- package/lib/locale/vi-VN.json +62 -0
- package/lib/locale/zh-CN.json +58 -46
- package/lib/locale/zh-TW.json +62 -0
- package/lib/models/CollectionFieldModel.d.ts +6 -2
- package/lib/models/CollectionFieldModel.js +60 -14
- package/lib/models/flowModel.d.ts +43 -4
- package/lib/models/flowModel.js +128 -26
- package/lib/models/forkFlowModel.d.ts +6 -2
- package/lib/models/forkFlowModel.js +9 -2
- package/lib/provider.d.ts +3 -1
- package/lib/provider.js +4 -3
- package/lib/reactive/index.d.ts +10 -0
- package/lib/reactive/index.js +41 -0
- package/lib/reactive/observer.d.ts +19 -0
- package/lib/reactive/observer.js +109 -0
- package/lib/resources/baseRecordResource.d.ts +1 -0
- package/lib/resources/baseRecordResource.js +14 -3
- package/lib/resources/multiRecordResource.d.ts +4 -2
- package/lib/resources/multiRecordResource.js +15 -6
- package/lib/resources/singleRecordResource.js +6 -3
- package/lib/resources/sqlResource.d.ts +1 -0
- package/lib/resources/sqlResource.js +22 -25
- package/lib/runjs-context/contexts/base.js +42 -6
- package/lib/runjs-context/snippets/global/clipboard-copy-text.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/clipboard-copy-text.snippet.js +61 -0
- package/lib/runjs-context/snippets/index.js +3 -0
- package/lib/runjs-context/snippets/scene/block/render-antd-icons.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-antd-icons.snippet.js +65 -0
- package/lib/runjs-context/snippets/scene/block/render-button-handler.snippet.js +6 -4
- package/lib/runjs-context/snippets/scene/block/render-info-card.snippet.js +15 -16
- package/lib/runjs-context/snippets/scene/block/render-react-jsx.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-react-jsx.snippet.js +58 -0
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +7 -7
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +24 -29
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +20 -21
- package/lib/scheduler/ModelOperationScheduler.d.ts +51 -0
- package/lib/scheduler/ModelOperationScheduler.js +262 -0
- package/lib/types.d.ts +42 -7
- package/lib/types.js +4 -3
- package/lib/utils/associationObjectVariable.d.ts +32 -0
- package/lib/utils/associationObjectVariable.js +157 -0
- package/lib/utils/createCollectionContextMeta.d.ts +1 -1
- package/lib/utils/createCollectionContextMeta.js +8 -4
- package/lib/utils/createEphemeralContext.d.ts +13 -0
- package/lib/utils/createEphemeralContext.js +140 -0
- package/lib/utils/flows.d.ts +10 -0
- package/lib/utils/flows.js +48 -0
- package/lib/utils/index.d.ts +7 -3
- package/lib/utils/index.js +20 -0
- package/lib/utils/jsxTransform.d.ts +15 -0
- package/lib/utils/jsxTransform.js +68 -0
- package/lib/utils/params-resolvers.js +3 -3
- package/lib/utils/parsePathnameToViewParams.d.ts +1 -1
- package/lib/utils/parsePathnameToViewParams.js +41 -5
- package/lib/utils/pruneFilter.d.ts +21 -0
- package/lib/utils/pruneFilter.js +52 -0
- package/lib/utils/safeGlobals.d.ts +5 -3
- package/lib/utils/safeGlobals.js +42 -1
- package/lib/utils/schema-utils.d.ts +6 -0
- package/lib/utils/schema-utils.js +71 -6
- package/lib/utils/serverContextParams.d.ts +3 -0
- package/lib/utils/serverContextParams.js +2 -0
- package/lib/utils/translation.d.ts +4 -1
- package/lib/utils/translation.js +6 -2
- package/lib/utils/variablesParams.d.ts +21 -5
- package/lib/utils/variablesParams.js +103 -34
- package/lib/views/DialogComponent.js +1 -5
- package/lib/views/DrawerComponent.js +18 -9
- package/lib/views/PageComponent.js +3 -4
- package/lib/views/ViewNavigation.d.ts +11 -15
- package/lib/views/ViewNavigation.js +37 -19
- package/lib/views/createViewMeta.d.ts +3 -2
- package/lib/views/createViewMeta.js +164 -53
- package/lib/views/useDialog.d.ts +2 -1
- package/lib/views/useDialog.js +36 -30
- package/lib/views/useDrawer.d.ts +2 -1
- package/lib/views/useDrawer.js +33 -26
- package/lib/views/usePage.d.ts +2 -1
- package/lib/views/usePage.js +40 -29
- package/package.json +6 -3
- package/src/BlockScopedFlowEngine.ts +88 -0
- package/src/JSRunner.ts +3 -0
- package/src/ViewScopedFlowEngine.ts +16 -0
- package/src/__tests__/JSRunner.test.ts +62 -53
- package/src/__tests__/blockScopedFlowEngine.test.ts +154 -0
- package/src/__tests__/createViewMeta.popup.test.ts +142 -0
- package/src/__tests__/flow-engine.test.ts +3 -0
- package/src/__tests__/flowContext.test.ts +70 -0
- package/src/__tests__/flowEngine.destroyModel.test.ts +74 -0
- package/src/__tests__/flowEngine.moveModel.test.ts +43 -0
- package/src/__tests__/flowEngine.removeModel.test.ts +72 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +4 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +3 -2
- package/src/__tests__/flowSettings.open.test.tsx +2 -0
- package/src/__tests__/flowSettings.test.ts +2 -0
- package/src/__tests__/globalFlowRegistry.test.ts +1 -1
- package/src/__tests__/modelOperationScheduler.test.ts +346 -0
- package/src/__tests__/objectVariable.test.ts +464 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +12 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +98 -0
- package/src/acl/Acl.tsx +85 -31
- package/src/acl/__tests__/Acl.test.tsx +43 -1
- package/src/components/DynamicFlowsEditor.tsx +0 -10
- package/src/components/FieldModelRenderer.tsx +15 -8
- package/src/components/FieldSkeleton.tsx +27 -0
- package/src/components/FlowContextSelector.tsx +20 -2
- package/src/components/FlowModelRenderer.tsx +46 -12
- package/src/components/FormItem.tsx +8 -1
- package/src/components/MobilePopup.style.ts +220 -0
- package/src/components/MobilePopup.tsx +86 -0
- package/src/components/__tests__/FlowModelRenderer.test.tsx +89 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +1 -1
- package/src/components/common/withFlowDesignMode.tsx +5 -5
- package/src/components/index.ts +1 -0
- package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +34 -17
- package/src/components/settings/wrappers/component/SelectWithTitle.tsx +110 -0
- package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +82 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +260 -121
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +34 -18
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +56 -18
- package/src/components/settings/wrappers/contextual/StepSettings.tsx +1 -2
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +12 -6
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +565 -0
- package/src/components/settings/wrappers/embedded/FlowSettings.tsx +47 -35
- package/src/components/settings/wrappers/embedded/FlowsSettings.tsx +1 -1
- package/src/components/settings/wrappers/embedded/FlowsSettingsContent.tsx +64 -42
- package/src/components/subModel/AddSubModelButton.tsx +104 -9
- package/src/components/subModel/LazyDropdown.tsx +14 -14
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +168 -7
- package/src/components/subModel/__tests__/utils.test.ts +12 -12
- package/src/components/subModel/utils.ts +25 -6
- package/src/components/variables/VariableInput.tsx +5 -3
- package/src/components/variables/types.ts +2 -0
- package/src/components/variables/utils.ts +7 -3
- package/src/data-source/index.ts +169 -11
- package/src/data-source/jioToJoiSchema.ts +1 -0
- package/src/emitter.ts +14 -0
- package/src/executor/FlowExecutor.ts +56 -8
- package/src/executor/__tests__/ctx-defs-injection.test.ts +197 -0
- package/src/flow-registry/GlobalFlowRegistry.ts +1 -0
- package/src/flow-registry/InstanceFlowRegistry.ts +1 -0
- package/src/flow-registry/__tests__/globalFlowRegistry.test.ts +54 -0
- package/src/flowContext.ts +144 -29
- package/src/flowEngine.ts +328 -8
- package/src/flowSettings.ts +47 -19
- package/src/hooks/useApplyAutoFlows.ts +3 -3
- package/src/index.ts +4 -2
- package/src/locale/de-DE.json +62 -0
- package/src/locale/en-US.json +57 -45
- package/src/locale/es-ES.json +62 -0
- package/src/locale/fr-FR.json +62 -0
- package/src/locale/hu-HU.json +62 -0
- package/src/locale/id-ID.json +62 -0
- package/src/locale/it-IT.json +62 -0
- package/src/locale/ja-JP.json +62 -0
- package/src/locale/ko-KR.json +62 -0
- package/src/locale/nl-NL.json +62 -0
- package/src/locale/pt-BR.json +62 -0
- package/src/locale/ru-RU.json +62 -0
- package/src/locale/tr-TR.json +62 -0
- package/src/locale/uk-UA.json +62 -0
- package/src/locale/vi-VN.json +62 -0
- package/src/locale/zh-CN.json +58 -46
- package/src/locale/zh-TW.json +62 -0
- package/src/models/CollectionFieldModel.tsx +79 -17
- package/src/models/__tests__/dispatchEvent.behavior.test.ts +169 -0
- package/src/models/__tests__/flowEngine.resolveUse.test.ts +170 -0
- package/src/models/__tests__/flowModel.getFlows.sort.test.ts +29 -5
- package/src/models/__tests__/flowModel.scheduleModelOperation.test.tsx +129 -0
- package/src/models/__tests__/flowModel.test.ts +65 -27
- package/src/models/__tests__/forkFlowModel.test.ts +40 -7
- package/src/models/flowModel.tsx +192 -30
- package/src/models/forkFlowModel.ts +11 -3
- package/src/provider.tsx +5 -5
- package/src/reactive/__tests__/observer.test.tsx +211 -0
- package/src/reactive/index.ts +11 -0
- package/src/reactive/observer.tsx +101 -0
- package/src/resources/baseRecordResource.ts +15 -3
- package/src/resources/multiRecordResource.ts +17 -8
- package/src/resources/singleRecordResource.ts +6 -3
- package/src/resources/sqlResource.ts +22 -26
- package/src/runjs-context/contexts/base.ts +47 -6
- package/src/runjs-context/snippets/global/clipboard-copy-text.snippet.ts +42 -0
- package/src/runjs-context/snippets/index.ts +3 -0
- package/src/runjs-context/snippets/scene/block/render-antd-icons.snippet.ts +46 -0
- package/src/runjs-context/snippets/scene/block/render-button-handler.snippet.ts +6 -4
- package/src/runjs-context/snippets/scene/block/render-info-card.snippet.ts +15 -16
- package/src/runjs-context/snippets/scene/block/render-react-jsx.snippet.ts +39 -0
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +7 -7
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +24 -29
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +20 -21
- package/src/scheduler/ModelOperationScheduler.ts +304 -0
- package/src/types.ts +50 -4
- package/src/utils/__tests__/createCollectionContextMeta.test.ts +51 -0
- package/src/utils/__tests__/flows.test.ts +65 -0
- package/src/utils/__tests__/jsxTransform.test.ts +38 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +25 -0
- package/src/utils/__tests__/pruneFilter.test.ts +38 -0
- package/src/utils/__tests__/safeGlobals.test.ts +23 -1
- package/src/utils/__tests__/utils.test.ts +114 -15
- package/src/utils/__tests__/variablesParams.test.ts +120 -0
- package/src/utils/associationObjectVariable.ts +180 -0
- package/src/utils/createCollectionContextMeta.ts +8 -3
- package/src/utils/createEphemeralContext.ts +142 -0
- package/src/utils/flows.ts +23 -0
- package/src/utils/index.ts +11 -2
- package/src/utils/jsxTransform.ts +39 -0
- package/src/utils/params-resolvers.ts +2 -2
- package/src/utils/parsePathnameToViewParams.ts +50 -6
- package/src/utils/pruneFilter.ts +41 -0
- package/src/utils/safeGlobals.ts +51 -4
- package/src/utils/schema-utils.ts +81 -3
- package/src/utils/serverContextParams.ts +5 -0
- package/src/utils/translation.ts +7 -2
- package/src/utils/variablesParams.ts +125 -42
- package/src/views/DialogComponent.tsx +1 -4
- package/src/views/DrawerComponent.tsx +19 -7
- package/src/views/PageComponent.tsx +2 -4
- package/src/views/ViewNavigation.ts +49 -43
- package/src/views/__tests__/FlowView.usePage.test.tsx +133 -0
- package/src/views/__tests__/ViewNavigation.test.ts +54 -34
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +132 -0
- package/src/views/createViewMeta.ts +179 -42
- package/src/views/useDialog.tsx +36 -24
- package/src/views/useDrawer.tsx +37 -24
- package/src/views/usePage.tsx +46 -27
package/lib/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
/// <reference types="react" />
|
|
10
10
|
import { ISchema } from '@formily/json-schema';
|
|
11
11
|
import { SubModelItem } from './components';
|
|
12
|
+
import type { PropertyOptions } from './flowContext';
|
|
12
13
|
import { FlowContext, FlowModelContext, FlowRuntimeContext, FlowSettingsContext } from './flowContext';
|
|
13
14
|
import type { FlowEngine } from './flowEngine';
|
|
14
15
|
import type { FlowModel } from './models';
|
|
@@ -93,6 +94,8 @@ export interface FlowDefinitionOptions<TModel extends FlowModel = FlowModel> {
|
|
|
93
94
|
* 仅填补缺失,不覆盖已有。固定返回形状:{ [stepKey]: params }
|
|
94
95
|
*/
|
|
95
96
|
defaultParams?: Record<string, any> | ((ctx: FlowModelContext) => StepParam | Promise<StepParam>);
|
|
97
|
+
enableTitle?: boolean;
|
|
98
|
+
divider?: 'top' | 'bottom';
|
|
96
99
|
}
|
|
97
100
|
export interface IModelComponentProps {
|
|
98
101
|
[key: string]: any;
|
|
@@ -110,12 +113,14 @@ export declare enum ActionScene {
|
|
|
110
113
|
BLOCK_LINKAGE_RULES = 1,
|
|
111
114
|
/** 表单字段级联动规则可用 */
|
|
112
115
|
FIELD_LINKAGE_RULES = 2,
|
|
116
|
+
/** 子表单字段级联动规则可用 */
|
|
117
|
+
SUB_FORM_FIELD_LINKAGE_RULES = 3,
|
|
113
118
|
/** 详情字段级联动规则可用 */
|
|
114
|
-
DETAILS_FIELD_LINKAGE_RULES =
|
|
119
|
+
DETAILS_FIELD_LINKAGE_RULES = 4,
|
|
115
120
|
/** 按钮级联动规则可用 */
|
|
116
|
-
ACTION_LINKAGE_RULES =
|
|
121
|
+
ACTION_LINKAGE_RULES = 5,
|
|
117
122
|
/** 动态事件流可用 */
|
|
118
|
-
DYNAMIC_EVENT_FLOW =
|
|
123
|
+
DYNAMIC_EVENT_FLOW = 6
|
|
119
124
|
}
|
|
120
125
|
/**
|
|
121
126
|
* Defines a reusable action with generic model type support.
|
|
@@ -132,6 +137,28 @@ export interface ActionDefinition<TModel extends FlowModel = FlowModel, TCtx ext
|
|
|
132
137
|
uiMode?: StepUIMode | ((ctx: FlowRuntimeContext<TModel>) => StepUIMode | Promise<StepUIMode>);
|
|
133
138
|
scene?: ActionScene | ActionScene[];
|
|
134
139
|
sort?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Whether the step/action requires params to be configured before use.
|
|
142
|
+
*/
|
|
143
|
+
paramsRequired?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Whether to hide this step/action from settings menus.
|
|
146
|
+
* - Supports static boolean and dynamic decision based on runtime context.
|
|
147
|
+
* - StepDefinition.hideInSettings can override the ActionDefinition value.
|
|
148
|
+
*/
|
|
149
|
+
hideInSettings?: boolean | ((ctx: TCtx) => boolean | Promise<boolean>);
|
|
150
|
+
/**
|
|
151
|
+
* 在执行 Action 前为 ctx 定义临时属性。
|
|
152
|
+
* - 仅支持 PropertyOptions 形态(例如:{ foo: { value: 5 } });
|
|
153
|
+
* - 或函数形式(接收 ctx,返回 PropertyOptions 对象;支持 Promise)。
|
|
154
|
+
*/
|
|
155
|
+
defineProperties?: Record<string, PropertyOptions> | ((ctx: TCtx) => Record<string, PropertyOptions> | Promise<Record<string, PropertyOptions>>);
|
|
156
|
+
/**
|
|
157
|
+
* 在执行 Action 前为 ctx 定义临时方法。
|
|
158
|
+
* - 支持 JSON 形式(对象的值应为函数)
|
|
159
|
+
* - 或函数形式(接收 ctx,返回方法对象;支持 Promise)
|
|
160
|
+
*/
|
|
161
|
+
defineMethods?: Record<string, (this: TCtx, ...args: any[]) => any> | ((ctx: TCtx) => Record<string, (this: TCtx, ...args: any[]) => any> | Promise<Record<string, (this: TCtx, ...args: any[]) => any>>);
|
|
135
162
|
}
|
|
136
163
|
/**
|
|
137
164
|
* Flow 事件名称集合。
|
|
@@ -160,8 +187,9 @@ export interface DispatchEventOptions {
|
|
|
160
187
|
*/
|
|
161
188
|
export type EventDefinition<TModel extends FlowModel = FlowModel, TCtx extends FlowContext = FlowContext> = ActionDefinition<TModel, TCtx>;
|
|
162
189
|
export type StepUIMode = 'dialog' | 'drawer' | 'embed' | {
|
|
163
|
-
type?: 'dialog' | 'drawer' | 'embed';
|
|
190
|
+
type?: 'dialog' | 'drawer' | 'embed' | 'select' | 'switch';
|
|
164
191
|
props?: Record<string, any>;
|
|
192
|
+
key?: string;
|
|
165
193
|
};
|
|
166
194
|
/**
|
|
167
195
|
* Step definition with unified support for both registered actions and inline handlers
|
|
@@ -173,8 +201,6 @@ export interface StepDefinition<TModel extends FlowModel = FlowModel> extends Pa
|
|
|
173
201
|
use?: string;
|
|
174
202
|
sort?: number;
|
|
175
203
|
preset?: boolean;
|
|
176
|
-
paramsRequired?: boolean;
|
|
177
|
-
hideInSettings?: boolean;
|
|
178
204
|
uiMode?: StepUIMode | ((ctx: FlowRuntimeContext<TModel>) => StepUIMode | Promise<StepUIMode>);
|
|
179
205
|
}
|
|
180
206
|
/**
|
|
@@ -225,6 +251,14 @@ export type ParamObject = {
|
|
|
225
251
|
* 已注册模型的类名
|
|
226
252
|
*/
|
|
227
253
|
export type RegisteredModelClassName = string;
|
|
254
|
+
/**
|
|
255
|
+
* resolveUse 返回类型:可返回目标 use,或 { use, stop } 包含中断标志。
|
|
256
|
+
*/
|
|
257
|
+
export type ResolveUseResult = RegisteredModelClassName | ModelConstructor | {
|
|
258
|
+
use: RegisteredModelClassName | ModelConstructor;
|
|
259
|
+
/** 标记是否终止后续 resolveUse 链;默认 false(继续解析) */
|
|
260
|
+
stop?: boolean;
|
|
261
|
+
};
|
|
228
262
|
/**
|
|
229
263
|
* Options for creating a model instance
|
|
230
264
|
*/
|
|
@@ -249,6 +283,7 @@ export interface IFlowModelRepository<T extends FlowModel = FlowModel> {
|
|
|
249
283
|
}): Promise<Record<string, any>>;
|
|
250
284
|
destroy(uid: string): Promise<boolean>;
|
|
251
285
|
move(sourceId: string, targetId: string, position: 'before' | 'after'): Promise<void>;
|
|
286
|
+
duplicate(uid: string): Promise<Record<string, any> | null>;
|
|
252
287
|
}
|
|
253
288
|
/**
|
|
254
289
|
* 步骤设置对话框的属性接口
|
|
@@ -350,7 +385,7 @@ export type FlowModelMeta = Pick<SubModelItem, 'key' | 'label' | 'icon' | 'child
|
|
|
350
385
|
* 是否在菜单中隐藏该模型类
|
|
351
386
|
* @default false
|
|
352
387
|
*/
|
|
353
|
-
hide?: boolean;
|
|
388
|
+
hide?: boolean | ((context: FlowModelContext) => boolean);
|
|
354
389
|
eventList?: {
|
|
355
390
|
label: string;
|
|
356
391
|
value: string;
|
package/lib/types.js
CHANGED
|
@@ -32,9 +32,10 @@ module.exports = __toCommonJS(types_exports);
|
|
|
32
32
|
var ActionScene = /* @__PURE__ */ ((ActionScene2) => {
|
|
33
33
|
ActionScene2[ActionScene2["BLOCK_LINKAGE_RULES"] = 1] = "BLOCK_LINKAGE_RULES";
|
|
34
34
|
ActionScene2[ActionScene2["FIELD_LINKAGE_RULES"] = 2] = "FIELD_LINKAGE_RULES";
|
|
35
|
-
ActionScene2[ActionScene2["
|
|
36
|
-
ActionScene2[ActionScene2["
|
|
37
|
-
ActionScene2[ActionScene2["
|
|
35
|
+
ActionScene2[ActionScene2["SUB_FORM_FIELD_LINKAGE_RULES"] = 3] = "SUB_FORM_FIELD_LINKAGE_RULES";
|
|
36
|
+
ActionScene2[ActionScene2["DETAILS_FIELD_LINKAGE_RULES"] = 4] = "DETAILS_FIELD_LINKAGE_RULES";
|
|
37
|
+
ActionScene2[ActionScene2["ACTION_LINKAGE_RULES"] = 5] = "ACTION_LINKAGE_RULES";
|
|
38
|
+
ActionScene2[ActionScene2["DYNAMIC_EVENT_FLOW"] = 6] = "DYNAMIC_EVENT_FLOW";
|
|
38
39
|
return ActionScene2;
|
|
39
40
|
})(ActionScene || {});
|
|
40
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { Collection } from '../data-source';
|
|
10
|
+
import type { FlowContext, PropertyMetaFactory } from '../flowContext';
|
|
11
|
+
/**
|
|
12
|
+
* 创建一个用于“对象类变量”(如 formValues / currentObject)的 `resolveOnServer` 判定函数。
|
|
13
|
+
* 仅当访问路径以“关联字段名”开头(且继续访问其子属性)时,返回 true 交由服务端解析;
|
|
14
|
+
* 否则在前端解析即可。
|
|
15
|
+
*
|
|
16
|
+
* @param collectionAccessor 返回当前对象所在 collection
|
|
17
|
+
* @param valueAccessor 可选,本地值访问器。若本地已存在目标子路径的值,则认为无需走后端,优先使用本地值。
|
|
18
|
+
* @returns `(subPath) => boolean` 判断是否需要服务端解析
|
|
19
|
+
*/
|
|
20
|
+
export declare function createAssociationSubpathResolver(collectionAccessor: () => Collection | null, valueAccessor?: () => unknown): (subPath: string) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 构建“对象类变量”的 PropertyMetaFactory:
|
|
23
|
+
* - 暴露集合字段结构(通过 createCollectionContextMeta)用于变量选择器;
|
|
24
|
+
* - 提供 buildVariablesParams:基于对象当前值,收集所有“已选择的关联字段”
|
|
25
|
+
* 以便服务端在 variables:resolve 时按需补全关联数据。
|
|
26
|
+
*
|
|
27
|
+
* @param collectionAccessor 获取集合对象,用于字段/元信息来源
|
|
28
|
+
* @param title 变量组标题(用于 UI 展示)
|
|
29
|
+
* @param valueAccessor 获取当前对象值(如 ctx.form.getFieldsValue() / ctx.currentObject)
|
|
30
|
+
* @returns PropertyMetaFactory
|
|
31
|
+
*/
|
|
32
|
+
export declare function createAssociationAwareObjectMetaFactory(collectionAccessor: () => Collection | null, title: string, valueAccessor: (ctx: FlowContext) => any): PropertyMetaFactory;
|
|
@@ -0,0 +1,157 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var associationObjectVariable_exports = {};
|
|
39
|
+
__export(associationObjectVariable_exports, {
|
|
40
|
+
createAssociationAwareObjectMetaFactory: () => createAssociationAwareObjectMetaFactory,
|
|
41
|
+
createAssociationSubpathResolver: () => createAssociationSubpathResolver
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(associationObjectVariable_exports);
|
|
44
|
+
var import_lodash = __toESM(require("lodash"));
|
|
45
|
+
var import_createCollectionContextMeta = require("./createCollectionContextMeta");
|
|
46
|
+
function baseFieldNameOf(subPath) {
|
|
47
|
+
if (!subPath) return void 0;
|
|
48
|
+
const m = subPath.match(/^([^.[]+)/);
|
|
49
|
+
return m == null ? void 0 : m[1];
|
|
50
|
+
}
|
|
51
|
+
__name(baseFieldNameOf, "baseFieldNameOf");
|
|
52
|
+
function findFieldByName(collection, name) {
|
|
53
|
+
var _a;
|
|
54
|
+
if (!collection || !name) return void 0;
|
|
55
|
+
const direct = collection.getField(name);
|
|
56
|
+
if (direct) return direct;
|
|
57
|
+
const fields = ((_a = collection.getFields) == null ? void 0 : _a.call(collection)) || [];
|
|
58
|
+
return fields.find((f) => f.name === name);
|
|
59
|
+
}
|
|
60
|
+
__name(findFieldByName, "findFieldByName");
|
|
61
|
+
function toFilterByTk(value, primaryKey) {
|
|
62
|
+
if (value == null) return void 0;
|
|
63
|
+
if (Array.isArray(primaryKey)) {
|
|
64
|
+
if (typeof value !== "object" || !value) return void 0;
|
|
65
|
+
const out = {};
|
|
66
|
+
for (const k of primaryKey) {
|
|
67
|
+
const v = value[k];
|
|
68
|
+
if (typeof v === "undefined" || v === null) return void 0;
|
|
69
|
+
out[k] = v;
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
if (typeof value === "string" || typeof value === "number") return value;
|
|
74
|
+
if (typeof value === "object") {
|
|
75
|
+
return value[primaryKey];
|
|
76
|
+
}
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
__name(toFilterByTk, "toFilterByTk");
|
|
80
|
+
function createAssociationSubpathResolver(collectionAccessor, valueAccessor) {
|
|
81
|
+
return (p) => {
|
|
82
|
+
if (!p || !p.includes(".")) return false;
|
|
83
|
+
const base = baseFieldNameOf(p);
|
|
84
|
+
if (!base) return false;
|
|
85
|
+
const collection = collectionAccessor();
|
|
86
|
+
const field = findFieldByName(collection, base);
|
|
87
|
+
const isAssoc = !!(field == null ? void 0 : field.isAssociationField());
|
|
88
|
+
if (!isAssoc) return false;
|
|
89
|
+
if (typeof valueAccessor === "function") {
|
|
90
|
+
const local = valueAccessor();
|
|
91
|
+
if (local && typeof local === "object") {
|
|
92
|
+
const v = import_lodash.default.get(local, p);
|
|
93
|
+
if (typeof v !== "undefined") return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
__name(createAssociationSubpathResolver, "createAssociationSubpathResolver");
|
|
100
|
+
function createAssociationAwareObjectMetaFactory(collectionAccessor, title, valueAccessor) {
|
|
101
|
+
const baseFactory = (0, import_createCollectionContextMeta.createCollectionContextMeta)(collectionAccessor, title, true);
|
|
102
|
+
const factory = /* @__PURE__ */ __name(async () => {
|
|
103
|
+
const base = await baseFactory();
|
|
104
|
+
if (!base) return null;
|
|
105
|
+
const meta = {
|
|
106
|
+
...base,
|
|
107
|
+
buildVariablesParams: /* @__PURE__ */ __name((ctx) => {
|
|
108
|
+
var _a;
|
|
109
|
+
const collection = collectionAccessor();
|
|
110
|
+
const obj = valueAccessor(ctx);
|
|
111
|
+
if (!collection || !obj || typeof obj !== "object") return {};
|
|
112
|
+
const params = {};
|
|
113
|
+
const fields = ((_a = collection.getFields) == null ? void 0 : _a.call(collection)) || [];
|
|
114
|
+
for (const field of fields) {
|
|
115
|
+
const name = field.name;
|
|
116
|
+
if (!name) continue;
|
|
117
|
+
if (!field.isAssociationField()) continue;
|
|
118
|
+
const target = field.target;
|
|
119
|
+
const targetCollection = field.targetCollection;
|
|
120
|
+
if (!target || !targetCollection) continue;
|
|
121
|
+
const primaryKey = targetCollection.filterTargetKey;
|
|
122
|
+
const associationValue = obj[name];
|
|
123
|
+
if (associationValue == null) continue;
|
|
124
|
+
if (Array.isArray(associationValue)) {
|
|
125
|
+
const ids = associationValue.map((item) => toFilterByTk(item, primaryKey)).filter((v) => v != null);
|
|
126
|
+
if (ids.length) {
|
|
127
|
+
params[name] = {
|
|
128
|
+
collection: target,
|
|
129
|
+
dataSourceKey: targetCollection.dataSourceKey,
|
|
130
|
+
filterByTk: ids
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
const id = toFilterByTk(associationValue, primaryKey);
|
|
135
|
+
if (id != null) {
|
|
136
|
+
params[name] = {
|
|
137
|
+
collection: target,
|
|
138
|
+
dataSourceKey: targetCollection.dataSourceKey,
|
|
139
|
+
filterByTk: id
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return params;
|
|
145
|
+
}, "buildVariablesParams")
|
|
146
|
+
};
|
|
147
|
+
return meta;
|
|
148
|
+
}, "factory");
|
|
149
|
+
factory.title = title;
|
|
150
|
+
return factory;
|
|
151
|
+
}
|
|
152
|
+
__name(createAssociationAwareObjectMetaFactory, "createAssociationAwareObjectMetaFactory");
|
|
153
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
+
0 && (module.exports = {
|
|
155
|
+
createAssociationAwareObjectMetaFactory,
|
|
156
|
+
createAssociationSubpathResolver
|
|
157
|
+
});
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { Collection } from '../data-source';
|
|
10
10
|
import type { PropertyMetaFactory } from '../flowContext';
|
|
11
|
-
export declare function createCollectionContextMeta(collectionOrFactory: Collection | (() => Collection | null), title?: string): PropertyMetaFactory;
|
|
11
|
+
export declare function createCollectionContextMeta(collectionOrFactory: Collection | (() => Collection | null), title?: string, includeNonFilterable?: boolean): PropertyMetaFactory;
|
|
@@ -32,7 +32,7 @@ __export(createCollectionContextMeta_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(createCollectionContextMeta_exports);
|
|
33
33
|
const RELATION_FIELD_TYPES = ["belongsTo", "hasOne", "hasMany", "belongsToMany", "belongsToArray"];
|
|
34
34
|
const NUMERIC_FIELD_TYPES = ["integer", "float", "double", "decimal"];
|
|
35
|
-
function createFieldMetadata(field) {
|
|
35
|
+
function createFieldMetadata(field, includeNonFilterable) {
|
|
36
36
|
const baseProperties = createMetaBaseProperties(field);
|
|
37
37
|
if (field.isAssociationField()) {
|
|
38
38
|
const targetCollection = field.targetCollection;
|
|
@@ -49,7 +49,9 @@ function createFieldMetadata(field) {
|
|
|
49
49
|
properties: /* @__PURE__ */ __name(async () => {
|
|
50
50
|
const subProperties = {};
|
|
51
51
|
targetCollection.fields.forEach((subField) => {
|
|
52
|
-
|
|
52
|
+
if (includeNonFilterable || subField.filterable) {
|
|
53
|
+
subProperties[subField.name] = createFieldMetadata(subField, includeNonFilterable);
|
|
54
|
+
}
|
|
53
55
|
});
|
|
54
56
|
return subProperties;
|
|
55
57
|
}, "properties")
|
|
@@ -89,7 +91,7 @@ function createMetaBaseProperties(field) {
|
|
|
89
91
|
};
|
|
90
92
|
}
|
|
91
93
|
__name(createMetaBaseProperties, "createMetaBaseProperties");
|
|
92
|
-
function createCollectionContextMeta(collectionOrFactory, title) {
|
|
94
|
+
function createCollectionContextMeta(collectionOrFactory, title, includeNonFilterable) {
|
|
93
95
|
const metaFn = /* @__PURE__ */ __name(async () => {
|
|
94
96
|
const collection = typeof collectionOrFactory === "function" ? collectionOrFactory() : collectionOrFactory;
|
|
95
97
|
if (!collection) {
|
|
@@ -101,7 +103,9 @@ function createCollectionContextMeta(collectionOrFactory, title) {
|
|
|
101
103
|
properties: /* @__PURE__ */ __name(async () => {
|
|
102
104
|
const properties = {};
|
|
103
105
|
collection.fields.forEach((field) => {
|
|
104
|
-
|
|
106
|
+
if (includeNonFilterable || field.filterable) {
|
|
107
|
+
properties[field.name] = createFieldMetadata(field, includeNonFilterable);
|
|
108
|
+
}
|
|
105
109
|
});
|
|
106
110
|
return properties;
|
|
107
111
|
}, "properties")
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { FlowContext } from '../flowContext';
|
|
10
|
+
import type { ActionDefinition } from '../types';
|
|
11
|
+
type ContextDefsLike<TCtx extends FlowContext> = Partial<Pick<ActionDefinition<any, TCtx>, 'defineProperties' | 'defineMethods'>> | null | undefined;
|
|
12
|
+
export declare function createEphemeralContext<TCtx extends FlowContext>(parent: TCtx, contextDefs?: ContextDefsLike<TCtx>): Promise<TCtx>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
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 createEphemeralContext_exports = {};
|
|
29
|
+
__export(createEphemeralContext_exports, {
|
|
30
|
+
createEphemeralContext: () => createEphemeralContext
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(createEphemeralContext_exports);
|
|
33
|
+
var import_flowContext = require("../flowContext");
|
|
34
|
+
async function createEphemeralContext(parent, contextDefs) {
|
|
35
|
+
if (contextDefs == null || !contextDefs.defineProperties && !contextDefs.defineMethods) {
|
|
36
|
+
return parent;
|
|
37
|
+
}
|
|
38
|
+
const scoped = new import_flowContext.FlowContext();
|
|
39
|
+
scoped.addDelegate(parent);
|
|
40
|
+
const scopedProxy = scoped.createProxy();
|
|
41
|
+
const scopedObj = scopedProxy;
|
|
42
|
+
const parentObj = parent;
|
|
43
|
+
const getFromParent = /* @__PURE__ */ __name((key) => {
|
|
44
|
+
const val = Reflect.get(parentObj, key, parentObj);
|
|
45
|
+
return typeof val === "function" ? val.bind(parent) : val;
|
|
46
|
+
}, "getFromParent");
|
|
47
|
+
const hasInScopedOrParent = /* @__PURE__ */ __name((key) => key === "defineProperty" || key === "defineMethod" || Reflect.has(scopedObj, key) || Reflect.has(parentObj, key), "hasInScopedOrParent");
|
|
48
|
+
const injectionProxy = new Proxy(scopedProxy, {
|
|
49
|
+
get(_t, key, receiver) {
|
|
50
|
+
if (typeof key === "string") {
|
|
51
|
+
if (key === "defineProperty") {
|
|
52
|
+
return (propKey, options) => scoped.defineProperty(propKey, options);
|
|
53
|
+
}
|
|
54
|
+
if (key === "defineMethod") {
|
|
55
|
+
return (name, fn, des) => scoped.defineMethod(name, fn, des);
|
|
56
|
+
}
|
|
57
|
+
if (Reflect.has(scopedObj, key)) {
|
|
58
|
+
return Reflect.get(scopedObj, key, receiver);
|
|
59
|
+
}
|
|
60
|
+
return getFromParent(key);
|
|
61
|
+
}
|
|
62
|
+
return Reflect.get(scopedObj, key, receiver);
|
|
63
|
+
},
|
|
64
|
+
set(_t, key, value) {
|
|
65
|
+
return Reflect.set(parentObj, key, value);
|
|
66
|
+
},
|
|
67
|
+
has(_t, key) {
|
|
68
|
+
return hasInScopedOrParent(key);
|
|
69
|
+
},
|
|
70
|
+
getOwnPropertyDescriptor(_t, key) {
|
|
71
|
+
return Object.getOwnPropertyDescriptor(scopedObj, key) || Object.getOwnPropertyDescriptor(parentObj, key);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (contextDefs) {
|
|
75
|
+
const defs = Array.isArray(contextDefs) ? contextDefs : [contextDefs];
|
|
76
|
+
for (const defLike of defs) {
|
|
77
|
+
if (!defLike) continue;
|
|
78
|
+
const dp = defLike.defineProperties;
|
|
79
|
+
if (dp) {
|
|
80
|
+
const raw = typeof dp === "function" ? await dp(injectionProxy) : dp;
|
|
81
|
+
if (!raw || typeof raw !== "object") {
|
|
82
|
+
throw new TypeError("defineProperties must return an object of PropertyOptions");
|
|
83
|
+
}
|
|
84
|
+
const propsDef = raw;
|
|
85
|
+
for (const [key, options] of Object.entries(propsDef)) {
|
|
86
|
+
if (!options || typeof options !== "object") {
|
|
87
|
+
throw new TypeError(`defineProperties['${key}'] must be a PropertyOptions object`);
|
|
88
|
+
}
|
|
89
|
+
scoped.defineProperty(key, options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const dm = defLike.defineMethods;
|
|
93
|
+
if (dm) {
|
|
94
|
+
const raw = typeof dm === "function" ? await dm(injectionProxy) : dm;
|
|
95
|
+
if (!raw || typeof raw !== "object") {
|
|
96
|
+
throw new TypeError("defineMethods must return an object of functions");
|
|
97
|
+
}
|
|
98
|
+
const methodsDef = raw;
|
|
99
|
+
for (const [key, fn] of Object.entries(methodsDef)) {
|
|
100
|
+
if (typeof fn !== "function") {
|
|
101
|
+
throw new TypeError(`defineMethods['${key}'] must be a function`);
|
|
102
|
+
}
|
|
103
|
+
scoped.defineMethod(key, fn);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const outerProxy = new Proxy(scopedProxy, {
|
|
109
|
+
get(_t, key, receiver) {
|
|
110
|
+
if (typeof key === "string") {
|
|
111
|
+
if (key === "defineProperty") {
|
|
112
|
+
return (propKey, options) => parent.defineProperty(propKey, options);
|
|
113
|
+
}
|
|
114
|
+
if (key === "defineMethod") {
|
|
115
|
+
return (name, fn, des) => parent.defineMethod(name, fn, des);
|
|
116
|
+
}
|
|
117
|
+
if (Reflect.has(scopedObj, key)) {
|
|
118
|
+
return Reflect.get(scopedObj, key, receiver);
|
|
119
|
+
}
|
|
120
|
+
return getFromParent(key);
|
|
121
|
+
}
|
|
122
|
+
return Reflect.get(scopedObj, key, receiver);
|
|
123
|
+
},
|
|
124
|
+
set(_t, key, value) {
|
|
125
|
+
return Reflect.set(parentObj, key, value);
|
|
126
|
+
},
|
|
127
|
+
has(_t, key) {
|
|
128
|
+
return hasInScopedOrParent(key);
|
|
129
|
+
},
|
|
130
|
+
getOwnPropertyDescriptor(_t, key) {
|
|
131
|
+
return Object.getOwnPropertyDescriptor(scopedObj, key) || Object.getOwnPropertyDescriptor(parentObj, key);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return outerProxy;
|
|
135
|
+
}
|
|
136
|
+
__name(createEphemeralContext, "createEphemeralContext");
|
|
137
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
138
|
+
0 && (module.exports = {
|
|
139
|
+
createEphemeralContext
|
|
140
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
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 { FlowDefinition } from '../FlowDefinition';
|
|
10
|
+
export declare const isBeforeRenderFlow: (flow: FlowDefinition) => boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 flows_exports = {};
|
|
29
|
+
__export(flows_exports, {
|
|
30
|
+
isBeforeRenderFlow: () => isBeforeRenderFlow
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(flows_exports);
|
|
33
|
+
const isBeforeRenderFlow = /* @__PURE__ */ __name((flow) => {
|
|
34
|
+
if (typeof flow.on === "string") {
|
|
35
|
+
return flow.on === "beforeRender";
|
|
36
|
+
}
|
|
37
|
+
if (typeof flow.on === "object") {
|
|
38
|
+
return flow.on.eventName === "beforeRender";
|
|
39
|
+
}
|
|
40
|
+
if (!flow.on && flow.manual !== true) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}, "isBeforeRenderFlow");
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
isBeforeRenderFlow
|
|
48
|
+
});
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -12,11 +12,15 @@ export { FlowExitException } from './exceptions';
|
|
|
12
12
|
export { defineAction } from './flow-definitions';
|
|
13
13
|
export { isInheritedFrom } from './inheritance';
|
|
14
14
|
export { resolveCreateModelOptions, resolveDefaultParams, resolveExpressions } from './params-resolvers';
|
|
15
|
-
export { compileUiSchema, resolveStepUiSchema, resolveUiMode } from './schema-utils';
|
|
15
|
+
export { compileUiSchema, resolveStepUiSchema, resolveUiMode, shouldHideStepInSettings } from './schema-utils';
|
|
16
16
|
export { setupRuntimeContextSteps } from './setupRuntimeContextSteps';
|
|
17
17
|
export { createCollectionContextMeta } from './createCollectionContextMeta';
|
|
18
|
-
export {
|
|
18
|
+
export { createAssociationAwareObjectMetaFactory, createAssociationSubpathResolver } from './associationObjectVariable';
|
|
19
|
+
export { buildRecordMeta, collectContextParamsForTemplate, createCurrentRecordMetaFactory, createRecordResolveOnServerWithLocal, createRecordMetaFactory, extractUsedVariableNames, extractUsedVariablePaths, inferRecordRef, type RecordParamsBuilder, } from './variablesParams';
|
|
19
20
|
export { extractPropertyPath, formatPathToVariable, isVariableExpression } from './context';
|
|
20
21
|
export { clearAutoFlowError, getAutoFlowError, setAutoFlowError, type AutoFlowError } from './autoFlowError';
|
|
21
22
|
export { parsePathnameToViewParams, type ViewParam } from './parsePathnameToViewParams';
|
|
22
|
-
export { createSafeDocument, createSafeWindow } from './safeGlobals';
|
|
23
|
+
export { createSafeDocument, createSafeWindow, createSafeNavigator } from './safeGlobals';
|
|
24
|
+
export { createEphemeralContext } from './createEphemeralContext';
|
|
25
|
+
export { pruneFilter } from './pruneFilter';
|
|
26
|
+
export { isBeforeRenderFlow } from './flows';
|