@nocobase/flow-engine 2.0.0-alpha.10
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/LICENSE +661 -0
- package/README.md +30 -0
- package/lib/ContextPathProxy.d.ts +17 -0
- package/lib/ContextPathProxy.js +65 -0
- package/lib/ElementProxy.d.ts +17 -0
- package/lib/ElementProxy.js +93 -0
- package/lib/FlowContextProvider.d.ts +24 -0
- package/lib/FlowContextProvider.js +82 -0
- package/lib/FlowDefinition.d.ts +423 -0
- package/lib/FlowDefinition.js +257 -0
- package/lib/JSRunner.d.ts +32 -0
- package/lib/JSRunner.js +95 -0
- package/lib/ReactView.d.ts +20 -0
- package/lib/ReactView.js +120 -0
- package/lib/ViewScopedFlowEngine.d.ts +23 -0
- package/lib/ViewScopedFlowEngine.js +81 -0
- package/lib/acl/Acl.d.ts +31 -0
- package/lib/acl/Acl.js +115 -0
- package/lib/action-registry/BaseActionRegistry.d.ts +23 -0
- package/lib/action-registry/BaseActionRegistry.js +57 -0
- package/lib/action-registry/EngineActionRegistry.d.ts +20 -0
- package/lib/action-registry/EngineActionRegistry.js +47 -0
- package/lib/action-registry/ModelActionRegistry.d.ts +34 -0
- package/lib/action-registry/ModelActionRegistry.js +79 -0
- package/lib/components/DynamicFlowsEditor.d.ts +17 -0
- package/lib/components/DynamicFlowsEditor.js +49 -0
- package/lib/components/FieldModelRenderer.d.ts +10 -0
- package/lib/components/FieldModelRenderer.js +100 -0
- package/lib/components/FlowContextSelector.d.ts +11 -0
- package/lib/components/FlowContextSelector.js +221 -0
- package/lib/components/FlowErrorFallback.d.ts +25 -0
- package/lib/components/FlowErrorFallback.js +264 -0
- package/lib/components/FlowModelRenderer.d.ts +61 -0
- package/lib/components/FlowModelRenderer.js +214 -0
- package/lib/components/FormItem.d.ts +18 -0
- package/lib/components/FormItem.js +151 -0
- package/lib/components/common/FlowSettingsButton.d.ts +11 -0
- package/lib/components/common/FlowSettingsButton.js +66 -0
- package/lib/components/common/index.d.ts +9 -0
- package/lib/components/common/index.js +30 -0
- package/lib/components/common/withFlowDesignMode.d.ts +26 -0
- package/lib/components/common/withFlowDesignMode.js +61 -0
- package/lib/components/dnd/findModelUidPosition.d.ts +13 -0
- package/lib/components/dnd/findModelUidPosition.js +50 -0
- package/lib/components/dnd/gridDragPlanner.d.ts +130 -0
- package/lib/components/dnd/gridDragPlanner.js +497 -0
- package/lib/components/dnd/index.d.ts +24 -0
- package/lib/components/dnd/index.js +164 -0
- package/lib/components/index.d.ts +18 -0
- package/lib/components/index.js +48 -0
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.d.ts +46 -0
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.js +225 -0
- package/lib/components/settings/independents/dropdown/index.d.ts +9 -0
- package/lib/components/settings/independents/dropdown/index.js +30 -0
- package/lib/components/settings/independents/index.d.ts +1 -0
- package/lib/components/settings/independents/index.js +30 -0
- package/lib/components/settings/index.d.ts +10 -0
- package/lib/components/settings/index.js +32 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +24 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +501 -0
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.d.ts +45 -0
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +231 -0
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +111 -0
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +484 -0
- package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.d.ts +26 -0
- package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.js +342 -0
- package/lib/components/settings/wrappers/contextual/StepSettings.d.ts +23 -0
- package/lib/components/settings/wrappers/contextual/StepSettings.js +110 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.d.ts +20 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +212 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.d.ts +20 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.js +47 -0
- package/lib/components/settings/wrappers/contextual/index.d.ts +14 -0
- package/lib/components/settings/wrappers/contextual/index.js +40 -0
- package/lib/components/settings/wrappers/embedded/FlowSettings.d.ts +33 -0
- package/lib/components/settings/wrappers/embedded/FlowSettings.js +207 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettings.d.ts +41 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettings.js +84 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.d.ts +16 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.js +88 -0
- package/lib/components/settings/wrappers/embedded/index.d.ts +10 -0
- package/lib/components/settings/wrappers/embedded/index.js +32 -0
- package/lib/components/settings/wrappers/index.d.ts +2 -0
- package/lib/components/settings/wrappers/index.js +32 -0
- package/lib/components/subModel/AddSubModelButton.d.ts +62 -0
- package/lib/components/subModel/AddSubModelButton.js +415 -0
- package/lib/components/subModel/LazyDropdown.d.ts +55 -0
- package/lib/components/subModel/LazyDropdown.js +524 -0
- package/lib/components/subModel/index.d.ts +10 -0
- package/lib/components/subModel/index.js +32 -0
- package/lib/components/subModel/utils.d.ts +34 -0
- package/lib/components/subModel/utils.js +287 -0
- package/lib/components/variables/InlineVariableTag.d.ts +21 -0
- package/lib/components/variables/InlineVariableTag.js +123 -0
- package/lib/components/variables/SlateVariableEditor.d.ts +46 -0
- package/lib/components/variables/SlateVariableEditor.js +302 -0
- package/lib/components/variables/VariableInput.d.ts +11 -0
- package/lib/components/variables/VariableInput.js +334 -0
- package/lib/components/variables/VariableTag.d.ts +11 -0
- package/lib/components/variables/VariableTag.js +189 -0
- package/lib/components/variables/VariableTrigger.d.ts +20 -0
- package/lib/components/variables/VariableTrigger.js +136 -0
- package/lib/components/variables/index.d.ts +15 -0
- package/lib/components/variables/index.js +53 -0
- package/lib/components/variables/types.d.ts +93 -0
- package/lib/components/variables/types.js +24 -0
- package/lib/components/variables/useResolvedMetaTree.d.ts +19 -0
- package/lib/components/variables/useResolvedMetaTree.js +91 -0
- package/lib/components/variables/utils.d.ts +22 -0
- package/lib/components/variables/utils.js +177 -0
- package/lib/data-source/index.d.ts +180 -0
- package/lib/data-source/index.js +737 -0
- package/lib/data-source/jioToJoiSchema.d.ts +19 -0
- package/lib/data-source/jioToJoiSchema.js +114 -0
- package/lib/data-source/sortCollectionsByInherits.d.ts +10 -0
- package/lib/data-source/sortCollectionsByInherits.js +71 -0
- package/lib/decorators/index.d.ts +9 -0
- package/lib/decorators/index.js +36 -0
- package/lib/decorators/largeField.d.ts +9 -0
- package/lib/decorators/largeField.js +42 -0
- package/lib/emitter.d.ts +16 -0
- package/lib/emitter.js +58 -0
- package/lib/event-registry/BaseEventRegistry.d.ts +22 -0
- package/lib/event-registry/BaseEventRegistry.js +57 -0
- package/lib/event-registry/EngineEventRegistry.d.ts +19 -0
- package/lib/event-registry/EngineEventRegistry.js +47 -0
- package/lib/event-registry/ModelEventRegistry.d.ts +33 -0
- package/lib/event-registry/ModelEventRegistry.js +79 -0
- package/lib/executor/FlowExecutor.d.ts +25 -0
- package/lib/executor/FlowExecutor.js +290 -0
- package/lib/flow-registry/BaseFlowRegistry.d.ts +46 -0
- package/lib/flow-registry/BaseFlowRegistry.js +86 -0
- package/lib/flow-registry/GlobalFlowRegistry.d.ts +22 -0
- package/lib/flow-registry/GlobalFlowRegistry.js +95 -0
- package/lib/flow-registry/InstanceFlowRegistry.d.ts +21 -0
- package/lib/flow-registry/InstanceFlowRegistry.js +59 -0
- package/lib/flow-registry/index.d.ts +11 -0
- package/lib/flow-registry/index.js +34 -0
- package/lib/flowContext.d.ts +243 -0
- package/lib/flowContext.js +1337 -0
- package/lib/flowEngine.d.ts +340 -0
- package/lib/flowEngine.js +781 -0
- package/lib/flowI18n.d.ts +46 -0
- package/lib/flowI18n.js +117 -0
- package/lib/flowSettings.d.ts +266 -0
- package/lib/flowSettings.js +850 -0
- package/lib/hooks/index.d.ts +14 -0
- package/lib/hooks/index.js +40 -0
- package/lib/hooks/useApplyAutoFlows.d.ts +21 -0
- package/lib/hooks/useApplyAutoFlows.js +63 -0
- package/lib/hooks/useFlowModel.d.ts +29 -0
- package/lib/hooks/useFlowModel.js +72 -0
- package/lib/hooks/useFlowModelById.d.ts +11 -0
- package/lib/hooks/useFlowModelById.js +61 -0
- package/lib/hooks/useFlowSettingsContext.d.ts +20 -0
- package/lib/hooks/useFlowSettingsContext.js +61 -0
- package/lib/hooks/useFlowStep.d.ts +17 -0
- package/lib/hooks/useFlowStep.js +56 -0
- package/lib/hooks/useNiceDropdownMaxHeight.d.ts +13 -0
- package/lib/hooks/useNiceDropdownMaxHeight.js +52 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +93 -0
- package/lib/locale/en-US.json +61 -0
- package/lib/locale/index.d.ts +141 -0
- package/lib/locale/index.js +70 -0
- package/lib/locale/zh-CN.json +61 -0
- package/lib/models/CollectionFieldModel.d.ts +52 -0
- package/lib/models/CollectionFieldModel.js +280 -0
- package/lib/models/DisplayItemModel.d.ts +12 -0
- package/lib/models/DisplayItemModel.js +41 -0
- package/lib/models/EditableItemModel.d.ts +12 -0
- package/lib/models/EditableItemModel.js +41 -0
- package/lib/models/FilterableItemModel.d.ts +12 -0
- package/lib/models/FilterableItemModel.js +41 -0
- package/lib/models/flowModel.d.ts +342 -0
- package/lib/models/flowModel.js +1154 -0
- package/lib/models/forkFlowModel.d.ts +83 -0
- package/lib/models/forkFlowModel.js +280 -0
- package/lib/models/index.d.ts +14 -0
- package/lib/models/index.js +40 -0
- package/lib/provider.d.ts +22 -0
- package/lib/provider.js +115 -0
- package/lib/resources/apiResource.d.ts +34 -0
- package/lib/resources/apiResource.js +153 -0
- package/lib/resources/baseRecordResource.d.ts +61 -0
- package/lib/resources/baseRecordResource.js +264 -0
- package/lib/resources/filterItem.d.ts +33 -0
- package/lib/resources/filterItem.js +93 -0
- package/lib/resources/flowResource.d.ts +45 -0
- package/lib/resources/flowResource.js +146 -0
- package/lib/resources/index.d.ts +15 -0
- package/lib/resources/index.js +42 -0
- package/lib/resources/multiRecordResource.d.ts +53 -0
- package/lib/resources/multiRecordResource.js +230 -0
- package/lib/resources/singleRecordResource.d.ts +23 -0
- package/lib/resources/singleRecordResource.js +111 -0
- package/lib/resources/sqlResource.d.ts +73 -0
- package/lib/resources/sqlResource.js +294 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +73 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +91 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.js +58 -0
- package/lib/runjs-context/contexts/JSColumnRunJSContext.d.ts +15 -0
- package/lib/runjs-context/contexts/JSColumnRunJSContext.js +78 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.js +74 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +70 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.js +60 -0
- package/lib/runjs-context/contexts/base.d.ts +9 -0
- package/lib/runjs-context/contexts/base.js +169 -0
- package/lib/runjs-context/helpers.d.ts +20 -0
- package/lib/runjs-context/helpers.js +88 -0
- package/lib/runjs-context/registry.d.ts +20 -0
- package/lib/runjs-context/registry.js +61 -0
- package/lib/runjs-context/setup.d.ts +9 -0
- package/lib/runjs-context/setup.js +82 -0
- package/lib/runjs-context/snippets/global/api-request.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/api-request.snippet.js +57 -0
- package/lib/runjs-context/snippets/global/import-esm.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/import-esm.snippet.js +58 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.js +47 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.js +47 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.js +50 -0
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.js +54 -0
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.js +54 -0
- package/lib/runjs-context/snippets/global/query-selector.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/query-selector.snippet.js +53 -0
- package/lib/runjs-context/snippets/global/require-amd.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/require-amd.snippet.js +49 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.js +48 -0
- package/lib/runjs-context/snippets/index.d.ts +22 -0
- package/lib/runjs-context/snippets/index.js +213 -0
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +55 -0
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +99 -0
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +63 -0
- package/lib/runjs-context/snippets/scene/block/render-button-handler.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-button-handler.snippet.js +52 -0
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +57 -0
- package/lib/runjs-context/snippets/scene/block/render-info-card.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-info-card.snippet.js +72 -0
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +57 -0
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +100 -0
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +85 -0
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +283 -0
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +124 -0
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +52 -0
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +51 -0
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +50 -0
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +82 -0
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +80 -0
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +74 -0
- package/lib/runjs-context/snippets/scene/form/calculate-total.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/calculate-total.snippet.js +63 -0
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +81 -0
- package/lib/runjs-context/snippets/scene/form/conditional-required.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/conditional-required.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/form/copy-field-values.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/copy-field-values.snippet.js +74 -0
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +53 -0
- package/lib/runjs-context/snippets/scene/form/set-disabled.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/set-disabled.snippet.js +69 -0
- package/lib/runjs-context/snippets/scene/form/set-field-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/set-field-value.snippet.js +68 -0
- package/lib/runjs-context/snippets/scene/form/set-required.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/set-required.snippet.js +69 -0
- package/lib/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.js +67 -0
- package/lib/runjs-context/snippets/scene/form/toggle-visible.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/toggle-visible.snippet.js +69 -0
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/table/collection-selected-count.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/collection-selected-count.snippet.js +53 -0
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +79 -0
- package/lib/runjs-context/snippets/scene/table/destroy-selected.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/destroy-selected.snippet.js +55 -0
- package/lib/runjs-context/snippets/scene/table/export-selected-json.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/export-selected-json.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/table/iterate-selected-rows.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/iterate-selected-rows.snippet.js +52 -0
- package/lib/runjs-context/snippets/types.d.ts +24 -0
- package/lib/runjs-context/snippets/types.js +24 -0
- package/lib/types.d.ts +407 -0
- package/lib/types.js +43 -0
- package/lib/utils/autoFlowError.d.ts +16 -0
- package/lib/utils/autoFlowError.js +53 -0
- package/lib/utils/constants.d.ts +29 -0
- package/lib/utils/constants.js +77 -0
- package/lib/utils/context.d.ts +40 -0
- package/lib/utils/context.js +63 -0
- package/lib/utils/createCollectionContextMeta.d.ts +11 -0
- package/lib/utils/createCollectionContextMeta.js +117 -0
- package/lib/utils/exceptions.d.ts +22 -0
- package/lib/utils/exceptions.js +62 -0
- package/lib/utils/flow-definitions.d.ts +11 -0
- package/lib/utils/flow-definitions.js +40 -0
- package/lib/utils/index.d.ts +22 -0
- package/lib/utils/index.js +115 -0
- package/lib/utils/inheritance.d.ts +16 -0
- package/lib/utils/inheritance.js +53 -0
- package/lib/utils/params-resolvers.d.ts +51 -0
- package/lib/utils/params-resolvers.js +309 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +34 -0
- package/lib/utils/parsePathnameToViewParams.js +84 -0
- package/lib/utils/safeGlobals.d.ts +16 -0
- package/lib/utils/safeGlobals.js +179 -0
- package/lib/utils/schema-utils.d.ts +40 -0
- package/lib/utils/schema-utils.js +161 -0
- package/lib/utils/serverContextParams.d.ts +29 -0
- package/lib/utils/serverContextParams.js +106 -0
- package/lib/utils/setupRuntimeContextSteps.d.ts +19 -0
- package/lib/utils/setupRuntimeContextSteps.js +88 -0
- package/lib/utils/translation.d.ts +18 -0
- package/lib/utils/translation.js +58 -0
- package/lib/utils/variablesParams.d.ts +52 -0
- package/lib/utils/variablesParams.js +161 -0
- package/lib/views/DialogComponent.d.ts +22 -0
- package/lib/views/DialogComponent.js +98 -0
- package/lib/views/DrawerComponent.d.ts +11 -0
- package/lib/views/DrawerComponent.js +101 -0
- package/lib/views/FlowView.d.ts +76 -0
- package/lib/views/FlowView.js +81 -0
- package/lib/views/PageComponent.d.ts +10 -0
- package/lib/views/PageComponent.js +168 -0
- package/lib/views/ViewNavigation.d.ts +45 -0
- package/lib/views/ViewNavigation.js +97 -0
- package/lib/views/createViewMeta.d.ts +44 -0
- package/lib/views/createViewMeta.js +377 -0
- package/lib/views/index.d.ts +14 -0
- package/lib/views/index.js +51 -0
- package/lib/views/useDialog.d.ts +32 -0
- package/lib/views/useDialog.js +200 -0
- package/lib/views/useDrawer.d.ts +33 -0
- package/lib/views/useDrawer.js +220 -0
- package/lib/views/usePage.d.ts +32 -0
- package/lib/views/usePage.js +194 -0
- package/lib/views/usePatchElement.d.ts +10 -0
- package/lib/views/usePatchElement.js +54 -0
- package/lib/views/usePopover.d.ts +17 -0
- package/lib/views/usePopover.js +159 -0
- package/package.json +37 -0
- package/src/ContextPathProxy.ts +45 -0
- package/src/ElementProxy.ts +69 -0
- package/src/FlowContextProvider.tsx +42 -0
- package/src/FlowDefinition.ts +275 -0
- package/src/JSRunner.ts +84 -0
- package/src/ReactView.tsx +104 -0
- package/src/ViewScopedFlowEngine.ts +75 -0
- package/src/__tests__/ElementProxy.test.ts +51 -0
- package/src/__tests__/JSRunner.test.ts +92 -0
- package/src/__tests__/ReactView.test.tsx +63 -0
- package/src/__tests__/context-path-proxy.test.ts +35 -0
- package/src/__tests__/flow-engine.test.ts +189 -0
- package/src/__tests__/flowContext.test.ts +2012 -0
- package/src/__tests__/flowContextCreateJSRunner.test.ts +163 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +171 -0
- package/src/__tests__/flowI18n.test.ts +28 -0
- package/src/__tests__/flowModel.getFlows.test.ts +61 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +78 -0
- package/src/__tests__/flowRunJSContextDefine.test.ts +508 -0
- package/src/__tests__/flowRuntimeContext.test.ts +187 -0
- package/src/__tests__/flowSettings.open.test.tsx +1920 -0
- package/src/__tests__/flowSettings.test.ts +566 -0
- package/src/__tests__/globalFlowRegistry.test.ts +77 -0
- package/src/__tests__/isFieldInterfaceMatch.test.ts +51 -0
- package/src/__tests__/metaTreeNodeCache.test.ts +234 -0
- package/src/__tests__/path-aggregation.test.ts +85 -0
- package/src/__tests__/provider.test.tsx +28 -0
- package/src/__tests__/renderHiddenInConfig.test.tsx +91 -0
- package/src/__tests__/runjsContext.test.ts +241 -0
- package/src/__tests__/runjsContextImplementations.test.ts +217 -0
- package/src/__tests__/runjsContextRuntime.test.ts +269 -0
- package/src/__tests__/runjsEdgeCases.test.ts +281 -0
- package/src/__tests__/runjsLocales.test.ts +36 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +449 -0
- package/src/__tests__/runjsSnippets.test.ts +140 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +212 -0
- package/src/acl/Acl.tsx +109 -0
- package/src/acl/__tests__/Acl.test.tsx +72 -0
- package/src/action-registry/BaseActionRegistry.ts +46 -0
- package/src/action-registry/EngineActionRegistry.ts +32 -0
- package/src/action-registry/ModelActionRegistry.ts +75 -0
- package/src/action-registry/__tests__/engineActionRegistry.test.ts +43 -0
- package/src/action-registry/__tests__/modelActionRegistry.test.ts +107 -0
- package/src/components/DynamicFlowsEditor.tsx +318 -0
- package/src/components/FieldModelRenderer.tsx +68 -0
- package/src/components/FlowContextSelector.tsx +255 -0
- package/src/components/FlowErrorFallback.tsx +316 -0
- package/src/components/FlowModelRenderer.tsx +362 -0
- package/src/components/FormItem.tsx +136 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +226 -0
- package/src/components/__tests__/gridDragPlanner.test.ts +494 -0
- package/src/components/common/FlowSettingsButton.tsx +30 -0
- package/src/components/common/index.ts +10 -0
- package/src/components/common/withFlowDesignMode.tsx +49 -0
- package/src/components/dnd/README.md +149 -0
- package/src/components/dnd/findModelUidPosition.ts +26 -0
- package/src/components/dnd/gridDragPlanner.ts +659 -0
- package/src/components/dnd/index.tsx +128 -0
- package/src/components/index.ts +20 -0
- package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +279 -0
- package/src/components/settings/independents/dropdown/index.ts +10 -0
- package/src/components/settings/independents/index.ts +2 -0
- package/src/components/settings/index.ts +11 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +617 -0
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +292 -0
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +655 -0
- package/src/components/settings/wrappers/contextual/StepRequiredSettingsDialog.tsx +446 -0
- package/src/components/settings/wrappers/contextual/StepSettings.tsx +109 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +223 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDrawer.tsx +32 -0
- package/src/components/settings/wrappers/contextual/index.ts +15 -0
- package/src/components/settings/wrappers/embedded/FlowSettings.tsx +258 -0
- package/src/components/settings/wrappers/embedded/FlowsSettings.tsx +111 -0
- package/src/components/settings/wrappers/embedded/FlowsSettingsContent.tsx +96 -0
- package/src/components/settings/wrappers/embedded/index.ts +11 -0
- package/src/components/settings/wrappers/index.ts +5 -0
- package/src/components/subModel/AddSubModelButton.tsx +575 -0
- package/src/components/subModel/LazyDropdown.tsx +714 -0
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +1185 -0
- package/src/components/subModel/__tests__/buildWrapperFieldChildren.test.ts +192 -0
- package/src/components/subModel/__tests__/utils.test.ts +425 -0
- package/src/components/subModel/index.ts +12 -0
- package/src/components/subModel/utils.ts +278 -0
- package/src/components/variables/InlineVariableTag.tsx +97 -0
- package/src/components/variables/SlateVariableEditor.tsx +384 -0
- package/src/components/variables/VariableInput.tsx +360 -0
- package/src/components/variables/VariableTag.tsx +175 -0
- package/src/components/variables/VariableTrigger.tsx +116 -0
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +553 -0
- package/src/components/variables/__tests__/VariableInput.test.tsx +550 -0
- package/src/components/variables/__tests__/VariableTag.test.tsx +347 -0
- package/src/components/variables/__tests__/test-utils.tsx +62 -0
- package/src/components/variables/__tests__/utils.test.ts +310 -0
- package/src/components/variables/index.ts +16 -0
- package/src/components/variables/types.ts +100 -0
- package/src/components/variables/useResolvedMetaTree.ts +76 -0
- package/src/components/variables/utils.ts +192 -0
- package/src/data-source/__tests__/collection.test.ts +58 -0
- package/src/data-source/__tests__/index.test.ts +82 -0
- package/src/data-source/__tests__/jioToJoiSchema.test.ts +56 -0
- package/src/data-source/__tests__/sortCollectionsByInherits.test.ts +125 -0
- package/src/data-source/index.ts +816 -0
- package/src/data-source/jioToJoiSchema.ts +103 -0
- package/src/data-source/sortCollectionsByInherits.ts +61 -0
- package/src/decorators/index.ts +10 -0
- package/src/decorators/largeField.ts +14 -0
- package/src/emitter.ts +33 -0
- package/src/event-registry/BaseEventRegistry.ts +40 -0
- package/src/event-registry/EngineEventRegistry.ts +26 -0
- package/src/event-registry/ModelEventRegistry.ts +69 -0
- package/src/event-registry/__tests__/engineEventRegistry.test.ts +48 -0
- package/src/executor/FlowExecutor.ts +302 -0
- package/src/executor/__tests__/eventStep.test.ts +157 -0
- package/src/executor/__tests__/flowExecutor.test.ts +309 -0
- package/src/flow-registry/BaseFlowRegistry.ts +91 -0
- package/src/flow-registry/GlobalFlowRegistry.ts +82 -0
- package/src/flow-registry/InstanceFlowRegistry.ts +39 -0
- package/src/flow-registry/__tests__/globalFlowRegistry.test.ts +141 -0
- package/src/flow-registry/__tests__/instance-and-global-registry.test.ts +67 -0
- package/src/flow-registry/__tests__/instanceFlowRegistry.test.ts +83 -0
- package/src/flow-registry/index.ts +12 -0
- package/src/flowContext.ts +1742 -0
- package/src/flowEngine.ts +905 -0
- package/src/flowI18n.ts +96 -0
- package/src/flowSettings.ts +1045 -0
- package/src/hooks/index.ts +15 -0
- package/src/hooks/useApplyAutoFlows.ts +53 -0
- package/src/hooks/useFlowModel.tsx +59 -0
- package/src/hooks/useFlowModelById.ts +37 -0
- package/src/hooks/useFlowSettingsContext.tsx +37 -0
- package/src/hooks/useFlowStep.tsx +19 -0
- package/src/hooks/useNiceDropdownMaxHeight.ts +34 -0
- package/src/index.ts +46 -0
- package/src/locale/en-US.json +61 -0
- package/src/locale/index.ts +38 -0
- package/src/locale/zh-CN.json +61 -0
- package/src/models/CollectionFieldModel.tsx +306 -0
- package/src/models/DisplayItemModel.tsx +13 -0
- package/src/models/EditableItemModel.tsx +13 -0
- package/src/models/FilterableItemModel.tsx +13 -0
- package/src/models/__tests__/CollectionFieldModel.test.ts +122 -0
- package/src/models/__tests__/defaultParams-on-create.test.ts +83 -0
- package/src/models/__tests__/flow-model-oninit.test.ts +44 -0
- package/src/models/__tests__/flowModel.actions.integration.test.ts +100 -0
- package/src/models/__tests__/flowModel.getFlows.sort.test.ts +100 -0
- package/src/models/__tests__/flowModel.test.ts +2869 -0
- package/src/models/__tests__/flowRegistry.test.ts +512 -0
- package/src/models/__tests__/forkFlowModel.test.ts +1047 -0
- package/src/models/__tests__/model-actions.test.ts +70 -0
- package/src/models/__tests__/model-events.test.ts +69 -0
- package/src/models/flowModel.tsx +1421 -0
- package/src/models/forkFlowModel.ts +319 -0
- package/src/models/index.ts +17 -0
- package/src/provider.tsx +103 -0
- package/src/resources/__tests__/apiResource.test.ts +201 -0
- package/src/resources/__tests__/baseRecordResource.test.ts +262 -0
- package/src/resources/__tests__/filterItem.test.ts +260 -0
- package/src/resources/__tests__/flowResource.test.ts +127 -0
- package/src/resources/apiResource.ts +148 -0
- package/src/resources/baseRecordResource.ts +279 -0
- package/src/resources/filterItem.ts +74 -0
- package/src/resources/flowResource.ts +143 -0
- package/src/resources/index.ts +17 -0
- package/src/resources/multiRecordResource.ts +219 -0
- package/src/resources/singleRecordResource.ts +83 -0
- package/src/resources/sqlResource.ts +299 -0
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +46 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +64 -0
- package/src/runjs-context/contexts/JSCollectionActionRunJSContext.ts +31 -0
- package/src/runjs-context/contexts/JSColumnRunJSContext.ts +58 -0
- package/src/runjs-context/contexts/JSFieldRunJSContext.ts +48 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +43 -0
- package/src/runjs-context/contexts/JSRecordActionRunJSContext.ts +33 -0
- package/src/runjs-context/contexts/base.ts +155 -0
- package/src/runjs-context/helpers.ts +58 -0
- package/src/runjs-context/registry.ts +34 -0
- package/src/runjs-context/setup.ts +51 -0
- package/src/runjs-context/snippets/global/api-request.snippet.ts +38 -0
- package/src/runjs-context/snippets/global/import-esm.snippet.ts +39 -0
- package/src/runjs-context/snippets/global/message-error.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/message-success.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/notification-open.snippet.ts +31 -0
- package/src/runjs-context/snippets/global/open-view-dialog.snippet.ts +33 -0
- package/src/runjs-context/snippets/global/open-view-drawer.snippet.ts +33 -0
- package/src/runjs-context/snippets/global/query-selector.snippet.ts +34 -0
- package/src/runjs-context/snippets/global/require-amd.snippet.ts +30 -0
- package/src/runjs-context/snippets/global/window-open.snippet.ts +29 -0
- package/src/runjs-context/snippets/index.ts +195 -0
- package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +41 -0
- package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +80 -0
- package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +44 -0
- package/src/runjs-context/snippets/scene/block/render-button-handler.snippet.ts +33 -0
- package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/block/render-info-card.snippet.ts +53 -0
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +81 -0
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +66 -0
- package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +46 -0
- package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +264 -0
- package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +105 -0
- package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +33 -0
- package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +32 -0
- package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +31 -0
- package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +63 -0
- package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +61 -0
- package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +55 -0
- package/src/runjs-context/snippets/scene/form/calculate-total.snippet.ts +44 -0
- package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +62 -0
- package/src/runjs-context/snippets/scene/form/conditional-required.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/form/copy-field-values.snippet.ts +55 -0
- package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +39 -0
- package/src/runjs-context/snippets/scene/form/set-disabled.snippet.ts +50 -0
- package/src/runjs-context/snippets/scene/form/set-field-value.snippet.ts +49 -0
- package/src/runjs-context/snippets/scene/form/set-required.snippet.ts +50 -0
- package/src/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.ts +48 -0
- package/src/runjs-context/snippets/scene/form/toggle-visible.snippet.ts +50 -0
- package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/table/collection-selected-count.snippet.ts +34 -0
- package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +60 -0
- package/src/runjs-context/snippets/scene/table/destroy-selected.snippet.ts +36 -0
- package/src/runjs-context/snippets/scene/table/export-selected-json.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/table/iterate-selected-rows.snippet.ts +33 -0
- package/src/runjs-context/snippets/types.ts +21 -0
- package/src/types.ts +484 -0
- package/src/utils/__tests__/context.test.ts +93 -0
- package/src/utils/__tests__/params-resolvers.test.ts +652 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +104 -0
- package/src/utils/__tests__/safeGlobals.test.ts +29 -0
- package/src/utils/__tests__/utils.test.ts +1021 -0
- package/src/utils/__tests__/variablesParams.test.ts +52 -0
- package/src/utils/autoFlowError.ts +29 -0
- package/src/utils/constants.ts +60 -0
- package/src/utils/context.ts +70 -0
- package/src/utils/createCollectionContextMeta.ts +122 -0
- package/src/utils/exceptions.ts +36 -0
- package/src/utils/flow-definitions.ts +16 -0
- package/src/utils/index.ts +62 -0
- package/src/utils/inheritance.ts +39 -0
- package/src/utils/params-resolvers.ts +482 -0
- package/src/utils/parsePathnameToViewParams.ts +103 -0
- package/src/utils/safeGlobals.ts +188 -0
- package/src/utils/schema-utils.ts +201 -0
- package/src/utils/serverContextParams.ts +112 -0
- package/src/utils/setupRuntimeContextSteps.ts +89 -0
- package/src/utils/translation.ts +37 -0
- package/src/utils/variablesParams.ts +184 -0
- package/src/views/DialogComponent.tsx +79 -0
- package/src/views/DrawerComponent.tsx +72 -0
- package/src/views/FlowView.tsx +103 -0
- package/src/views/PageComponent.tsx +150 -0
- package/src/views/ViewNavigation.ts +122 -0
- package/src/views/__tests__/FlowView.test.ts +31 -0
- package/src/views/__tests__/ViewNavigation.test.ts +191 -0
- package/src/views/__tests__/usePatchElement.test.tsx +28 -0
- package/src/views/createViewMeta.ts +402 -0
- package/src/views/index.tsx +15 -0
- package/src/views/useDialog.tsx +194 -0
- package/src/views/useDrawer.tsx +229 -0
- package/src/views/usePage.tsx +185 -0
- package/src/views/usePatchElement.tsx +27 -0
- package/src/views/usePopover.tsx +131 -0
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
|
+
|
|
12
|
+
export class JSCollectionActionRunJSContext extends FlowRunJSContext {}
|
|
13
|
+
|
|
14
|
+
JSCollectionActionRunJSContext.define({
|
|
15
|
+
label: 'JSCollectionAction RunJS context',
|
|
16
|
+
properties: {
|
|
17
|
+
resource: `Collection resource instance providing access to selected rows, pagination, and data operations.
|
|
18
|
+
Use ctx.resource.selectedRows to get selected records.
|
|
19
|
+
Use ctx.resource.pagination for page info.`,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
JSCollectionActionRunJSContext.define(
|
|
24
|
+
{
|
|
25
|
+
label: 'JS 集合动作 RunJS 上下文',
|
|
26
|
+
properties: {
|
|
27
|
+
resource: '列表资源(包含选中行/分页信息等)',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{ locale: 'zh-CN' },
|
|
31
|
+
);
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* RunJS context for JSColumnModel (table custom column).
|
|
14
|
+
* Focused on per-row rendering with access to current record and cell element.
|
|
15
|
+
*/
|
|
16
|
+
export class JSColumnRunJSContext extends FlowRunJSContext {}
|
|
17
|
+
|
|
18
|
+
JSColumnRunJSContext.define({
|
|
19
|
+
label: 'JSColumn RunJS context',
|
|
20
|
+
properties: {
|
|
21
|
+
element:
|
|
22
|
+
'ElementProxy instance providing a safe DOM container for the current table cell. Supports innerHTML/append and basic DOM APIs.',
|
|
23
|
+
record: 'Current row record object (read-only).',
|
|
24
|
+
recordIndex: 'Index of the current row in the page (0-based).',
|
|
25
|
+
collection: 'Collection definition metadata (read-only).',
|
|
26
|
+
viewer:
|
|
27
|
+
'View controller providing dialog/drawer/embed helpers for interactions initiated from the cell (e.g., open details).',
|
|
28
|
+
React: 'React library',
|
|
29
|
+
antd: 'Ant Design library',
|
|
30
|
+
},
|
|
31
|
+
methods: {
|
|
32
|
+
onRefReady:
|
|
33
|
+
'Wait for cell DOM element to be ready before executing callback. Parameters: (ref, callback, timeout?) => void',
|
|
34
|
+
requireAsync: 'Load external library by URL: `const lib = await ctx.requireAsync(url)`',
|
|
35
|
+
importAsync: 'Dynamically import ESM module by URL: `const mod = await ctx.importAsync(url)`',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
JSColumnRunJSContext.define(
|
|
40
|
+
{
|
|
41
|
+
label: 'JS 列 RunJS 上下文',
|
|
42
|
+
properties: {
|
|
43
|
+
element: 'ElementProxy,表格单元格的安全 DOM 容器,支持 innerHTML/append 等',
|
|
44
|
+
record: '当前行记录对象(只读)',
|
|
45
|
+
recordIndex: '当前行索引(从 0 开始)',
|
|
46
|
+
collection: '集合定义元数据(只读)',
|
|
47
|
+
viewer: '视图控制器,可用于在单元格中触发抽屉/对话框/内嵌等交互',
|
|
48
|
+
React: 'React 库',
|
|
49
|
+
antd: 'Ant Design 库',
|
|
50
|
+
},
|
|
51
|
+
methods: {
|
|
52
|
+
onRefReady: '等待单元格 DOM 就绪后执行回调。参数:(ref, callback, timeout?)',
|
|
53
|
+
requireAsync: '按 URL 异步加载外部库:`const lib = await ctx.requireAsync(url)`',
|
|
54
|
+
importAsync: '按 URL 动态导入 ESM 模块:`const mod = await ctx.importAsync(url)`',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{ locale: 'zh-CN' },
|
|
58
|
+
);
|
|
@@ -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
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
|
+
|
|
12
|
+
export class JSFieldRunJSContext extends FlowRunJSContext {}
|
|
13
|
+
|
|
14
|
+
JSFieldRunJSContext.define({
|
|
15
|
+
label: 'JSField RunJS context',
|
|
16
|
+
properties: {
|
|
17
|
+
element: `ElementProxy instance providing a safe DOM container for field rendering.
|
|
18
|
+
Supports innerHTML, append, and other DOM manipulation methods.`,
|
|
19
|
+
value: `Current value of the field (read-only).
|
|
20
|
+
Contains the data value stored in this field.`,
|
|
21
|
+
record: `Current record data object (read-only).
|
|
22
|
+
Contains all field values of the parent record.`,
|
|
23
|
+
collection: `Collection definition metadata (read-only).
|
|
24
|
+
Provides schema information about the collection this field belongs to.`,
|
|
25
|
+
},
|
|
26
|
+
methods: {
|
|
27
|
+
onRefReady: `Wait for field container DOM element to be ready before executing callback.
|
|
28
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void
|
|
29
|
+
Example: ctx.onRefReady(ctx.ref, (el) => { el.innerHTML = ctx.value })`,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
JSFieldRunJSContext.define(
|
|
34
|
+
{
|
|
35
|
+
label: 'JS 字段 RunJS 上下文',
|
|
36
|
+
properties: {
|
|
37
|
+
element: 'ElementProxy,字段渲染容器,支持 innerHTML/append 等 DOM 操作',
|
|
38
|
+
value: '字段当前值(只读)',
|
|
39
|
+
record: '当前记录对象(只读,包含父记录全部字段值)',
|
|
40
|
+
collection: '集合定义元数据(只读,描述字段所属集合的 Schema)',
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
onRefReady:
|
|
44
|
+
'在字段容器 DOM 就绪后执行回调。参数:(ref, callback, timeout?);示例:ctx.onRefReady(ctx.ref, el => { el.innerHTML = ctx.value })',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{ locale: 'zh-CN' },
|
|
48
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
|
+
|
|
12
|
+
export class JSItemRunJSContext extends FlowRunJSContext {}
|
|
13
|
+
|
|
14
|
+
JSItemRunJSContext.define({
|
|
15
|
+
label: 'JSItem RunJS context',
|
|
16
|
+
properties: {
|
|
17
|
+
element: `ElementProxy instance providing a safe DOM container for form item rendering.
|
|
18
|
+
Supports innerHTML, append, and other DOM manipulation methods.`,
|
|
19
|
+
resource: `Current resource instance (read-only).
|
|
20
|
+
Provides access to the data resource associated with the current form context.`,
|
|
21
|
+
record: `Current record data object (read-only).
|
|
22
|
+
Contains all field values of the parent record.`,
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
onRefReady: `Wait for form item container DOM element to be ready before executing callback.
|
|
26
|
+
Parameters: (ref: React.RefObject, callback: (element: HTMLElement) => void, timeout?: number) => void`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
JSItemRunJSContext.define(
|
|
31
|
+
{
|
|
32
|
+
label: 'JS 表单项 RunJS 上下文',
|
|
33
|
+
properties: {
|
|
34
|
+
element: 'ElementProxy,表单项渲染容器,支持 innerHTML/append 等 DOM 操作',
|
|
35
|
+
resource: '当前资源(只读)',
|
|
36
|
+
record: '当前记录(只读)',
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
onRefReady: '容器就绪后执行回调。参数:(ref, callback, timeout?)',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{ locale: 'zh-CN' },
|
|
43
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
|
+
|
|
12
|
+
export class JSRecordActionRunJSContext extends FlowRunJSContext {}
|
|
13
|
+
|
|
14
|
+
JSRecordActionRunJSContext.define({
|
|
15
|
+
label: 'JSRecordAction RunJS context',
|
|
16
|
+
properties: {
|
|
17
|
+
record: `Current record data object (read-only).
|
|
18
|
+
Contains all field values of the record associated with this action.`,
|
|
19
|
+
filterByTk: `Primary key or filter key of the current record (read-only).
|
|
20
|
+
Used to identify the specific record in database operations.`,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
JSRecordActionRunJSContext.define(
|
|
25
|
+
{
|
|
26
|
+
label: 'JS 记录动作 RunJS 上下文',
|
|
27
|
+
properties: {
|
|
28
|
+
record: '当前记录(只读)',
|
|
29
|
+
filterByTk: '主键/过滤键(只读)',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{ locale: 'zh-CN' },
|
|
33
|
+
);
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
import { FlowRunJSContext } from '../../flowContext';
|
|
11
|
+
|
|
12
|
+
export function defineBaseContextMeta() {
|
|
13
|
+
FlowRunJSContext.define({
|
|
14
|
+
label: 'RunJS base',
|
|
15
|
+
properties: {
|
|
16
|
+
logger: 'Pino logger instance for structured logging. Example: `ctx.logger.info({ foo: 1 }, "message")`',
|
|
17
|
+
message:
|
|
18
|
+
'Ant Design global message API for displaying temporary messages. Example: `ctx.message.success("Operation completed")`',
|
|
19
|
+
notification:
|
|
20
|
+
'Ant Design notification API for displaying notification boxes. Example: `ctx.notification.open({ message: "Title", description: "Content" })`',
|
|
21
|
+
resource: 'Data resource accessible based on current user permissions',
|
|
22
|
+
urlSearchParams: 'URLSearchParams object containing query parameters from the current URL',
|
|
23
|
+
token: 'API authentication token for the current session',
|
|
24
|
+
role: 'Current user role information',
|
|
25
|
+
auth: 'Authentication context containing locale, role, user, and token information',
|
|
26
|
+
api: {
|
|
27
|
+
description: 'APIClient instance for making HTTP requests.',
|
|
28
|
+
detail: 'APIClient',
|
|
29
|
+
properties: {
|
|
30
|
+
request: {
|
|
31
|
+
description:
|
|
32
|
+
'Make an HTTP request using the APIClient instance. Parameters: (options: RequestOptions) => Promise<any>.',
|
|
33
|
+
detail: 'Promise<any>',
|
|
34
|
+
completion: {
|
|
35
|
+
insertText: `await ctx.api.request({ url: '', method: 'get', params: {} })`,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
i18n: {
|
|
41
|
+
description: 'An instance of i18next for managing internationalization.',
|
|
42
|
+
detail: 'i18next',
|
|
43
|
+
properties: {
|
|
44
|
+
language: 'Current active language code.',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
React: 'React namespace providing React library functions and hooks (available in RunJS environment)',
|
|
48
|
+
ReactDOM: 'ReactDOM client API including createRoot for rendering React components',
|
|
49
|
+
antd: 'Ant Design component library',
|
|
50
|
+
},
|
|
51
|
+
methods: {
|
|
52
|
+
t: 'Internationalization function for translating text. Parameters: (key: string, variables?: object) => string. Example: `ctx.t("Hello {name}", { name: "World" })`',
|
|
53
|
+
requireAsync:
|
|
54
|
+
'Asynchronously load external libraries from URL. Parameters: (url: string) => Promise<any>. Example: `const lodash = await ctx.requireAsync("https://cdn.jsdelivr.net/npm/lodash")`',
|
|
55
|
+
importAsync:
|
|
56
|
+
'Dynamically import ESM module by URL. Parameters: (url: string) => Promise<Module>. Example: `const mod = await ctx.importAsync("https://cdn.jsdelivr.net/npm/lit-html@2/+esm")`',
|
|
57
|
+
resolveJsonTemplate:
|
|
58
|
+
'Resolve JSON templates containing variable expressions with {{ }} syntax. Parameters: (template: any, context?: object) => any',
|
|
59
|
+
runAction: {
|
|
60
|
+
description:
|
|
61
|
+
'Execute a data action on the current resource. Parameters: (actionName: string, params: object) => Promise<any>. Example: `await ctx.runAction("create", { values: { name: "test" } })`',
|
|
62
|
+
detail: 'Promise<any>',
|
|
63
|
+
completion: {
|
|
64
|
+
insertText: `await ctx.runAction('create', { values: {} })`,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
openView: {
|
|
68
|
+
description: `Open a view component (page, modal, or drawer) by its unique identifier.
|
|
69
|
+
Parameters: (viewId: string, options?: OpenViewOptions) => Promise<void>
|
|
70
|
+
Options:
|
|
71
|
+
- params: Record<string, any> - Parameters passed to the view component
|
|
72
|
+
- mode: "page" | "modal" | "drawer" - Display mode (default: "drawer")
|
|
73
|
+
- title: string - Modal/drawer title
|
|
74
|
+
- width: number | string - Modal/drawer width
|
|
75
|
+
- navigation: boolean - Whether to use route navigation
|
|
76
|
+
- preventClose: boolean - Prevent closing the view
|
|
77
|
+
- viewUid: string - Custom view UID for routing
|
|
78
|
+
- isMobileLayout: boolean - Use mobile layout (displays as embed)
|
|
79
|
+
Examples:
|
|
80
|
+
- Modal with params: await ctx.openView("user-detail", { params: { id: 123 }, mode: "modal", title: "User Details", width: 800 })
|
|
81
|
+
- Drawer (default): await ctx.openView("settings-page")
|
|
82
|
+
- Page navigation: await ctx.openView("dashboard", { mode: "page" })`,
|
|
83
|
+
detail: 'Promise<void>',
|
|
84
|
+
completion: {
|
|
85
|
+
insertText: `await ctx.openView('view-id', { mode: 'drawer', params: {} })`,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
FlowRunJSContext.define(
|
|
92
|
+
{
|
|
93
|
+
label: 'RunJS 基础',
|
|
94
|
+
properties: {
|
|
95
|
+
logger: 'Pino 日志实例(结构化日志)。示例:`ctx.logger.info({ foo: 1 }, "message")`',
|
|
96
|
+
message: 'Ant Design 全局消息 API,用于显示临时提示。示例:`ctx.message.success("操作成功")`',
|
|
97
|
+
notification:
|
|
98
|
+
'Ant Design 通知 API,用于显示通知框。示例:`ctx.notification.open({ message: "标题", description: "内容" })`',
|
|
99
|
+
resource: '基于当前用户权限可访问的数据资源',
|
|
100
|
+
urlSearchParams: '当前 URL 的查询参数(URLSearchParams 对象)',
|
|
101
|
+
token: '当前会话的 API 认证 token',
|
|
102
|
+
role: '当前用户角色信息',
|
|
103
|
+
auth: '认证上下文,包含 locale、role、user、token 等信息',
|
|
104
|
+
api: {
|
|
105
|
+
description: '用于发起 HTTP 请求的 APIClient 实例',
|
|
106
|
+
detail: 'APIClient',
|
|
107
|
+
properties: {
|
|
108
|
+
request: {
|
|
109
|
+
description: '通过 ctx.api.request 发起 HTTP 请求,入参为 RequestOptions,返回 Promise。',
|
|
110
|
+
detail: 'Promise<any>',
|
|
111
|
+
completion: {
|
|
112
|
+
insertText: `await ctx.api.request({ url: '', method: 'get', params: {} })`,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
i18n: {
|
|
118
|
+
description: 'i18next 实例,可用于管理国际化',
|
|
119
|
+
detail: 'i18next',
|
|
120
|
+
properties: {
|
|
121
|
+
language: '当前激活的语言代码',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
React: 'React 命名空间,提供 React 函数与 hooks(RunJS 环境中可用)',
|
|
125
|
+
ReactDOM: 'ReactDOM 客户端 API,含 createRoot 等渲染方法',
|
|
126
|
+
antd: 'Ant Design 组件库(RunJS 环境中可用)',
|
|
127
|
+
},
|
|
128
|
+
methods: {
|
|
129
|
+
t: '国际化函数,用于翻译文案。参数:(key: string, variables?: object) => string。示例:`ctx.t("你好 {name}", { name: "世界" })`',
|
|
130
|
+
requireAsync:
|
|
131
|
+
'按 URL 异步加载外部库。参数:(url: string) => Promise<any>。示例:`const lodash = await ctx.requireAsync("https://cdn.jsdelivr.net/npm/lodash")`',
|
|
132
|
+
importAsync:
|
|
133
|
+
'按 URL 动态导入 ESM 模块(开发/生产均可用)。参数:(url: string) => Promise<Module>。示例:`const mod = await ctx.importAsync("https://cdn.jsdelivr.net/npm/lit-html@2/+esm")`',
|
|
134
|
+
resolveJsonTemplate: '解析含 {{ }} 变量表达式的 JSON 模板。参数:(template: any, context?: object) => any',
|
|
135
|
+
runAction: {
|
|
136
|
+
description:
|
|
137
|
+
'对当前资源执行数据动作。参数:(actionName: string, params: object) => Promise<any>。示例:`await ctx.runAction("create", { values: { name: "test" } })`',
|
|
138
|
+
detail: 'Promise<any>',
|
|
139
|
+
completion: {
|
|
140
|
+
insertText: `await ctx.runAction('create', { values: {} })`,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
openView: {
|
|
144
|
+
description:
|
|
145
|
+
'根据唯一标识打开视图(页面/弹窗/抽屉)。参数:(viewId: string, options?: OpenViewOptions) => Promise<void>`,常用选项:params、mode、title、width、navigation、preventClose、viewUid、isMobileLayout。',
|
|
146
|
+
detail: 'Promise<void>',
|
|
147
|
+
completion: {
|
|
148
|
+
insertText: `await ctx.openView('view-id', { mode: 'drawer', params: {} })`,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{ locale: 'zh-CN' },
|
|
154
|
+
);
|
|
155
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
import type { FlowContext } from '../flowContext';
|
|
11
|
+
import { JSRunner } from '../JSRunner';
|
|
12
|
+
import type { JSRunnerOptions } from '../JSRunner';
|
|
13
|
+
import { RunJSContextRegistry, getModelClassName, type RunJSVersion } from './registry';
|
|
14
|
+
|
|
15
|
+
function getLocale(ctx: any): string | undefined {
|
|
16
|
+
return ctx?.api?.auth?.locale || ctx?.i18n?.language || ctx?.locale;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getRunJSDocFor(ctx: FlowContext, { version = 'v1' as RunJSVersion } = {}) {
|
|
20
|
+
const modelClass = getModelClassName(ctx);
|
|
21
|
+
const ctor = RunJSContextRegistry.resolve(version, modelClass) || RunJSContextRegistry.resolve(version, '*');
|
|
22
|
+
const locale = getLocale(ctx);
|
|
23
|
+
if ((ctor as any)?.getDoc?.length) {
|
|
24
|
+
// prefer getDoc(locale)
|
|
25
|
+
return (ctor as any).getDoc(locale) || {};
|
|
26
|
+
}
|
|
27
|
+
return (ctor as any)?.getDoc?.() || {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createJSRunnerWithVersion(this: FlowContext, options?: JSRunnerOptions) {
|
|
31
|
+
const version = (options?.version as RunJSVersion) || ('v1' as RunJSVersion);
|
|
32
|
+
const modelClass = getModelClassName(this);
|
|
33
|
+
const ensureFlowContext = (obj: any): FlowContext => obj as FlowContext;
|
|
34
|
+
const Ctor = RunJSContextRegistry.resolve(version, modelClass) || RunJSContextRegistry.resolve(version, '*');
|
|
35
|
+
if (!Ctor) {
|
|
36
|
+
throw new Error('[RunJS] No RunJSContext registered for version/model.');
|
|
37
|
+
}
|
|
38
|
+
const runCtx = new (Ctor as any)(ensureFlowContext(this));
|
|
39
|
+
const globals: Record<string, any> = { ctx: runCtx, ...(options?.globals || {}) };
|
|
40
|
+
// 对字段/区块类上下文,默认注入 window/document 以支持在沙箱中访问 DOM API
|
|
41
|
+
if (modelClass === 'JSFieldModel' || modelClass === 'JSBlockModel') {
|
|
42
|
+
if (typeof window !== 'undefined') globals.window = window as any;
|
|
43
|
+
if (typeof document !== 'undefined') globals.document = document as any;
|
|
44
|
+
}
|
|
45
|
+
// 透传 JSRunnerOptions 其余配置(如 timeoutMs)
|
|
46
|
+
const { timeoutMs } = options || {};
|
|
47
|
+
return new JSRunner({ globals, timeoutMs });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function getRunJSScenesForModel(modelClass: string, version: RunJSVersion = 'v1'): string[] {
|
|
51
|
+
const meta = RunJSContextRegistry.getMeta(version, modelClass);
|
|
52
|
+
return Array.isArray(meta?.scenes) ? [...meta!.scenes!] : [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getRunJSScenesForContext(ctx: FlowContext, { version = 'v1' as RunJSVersion } = {}): string[] {
|
|
56
|
+
const modelClass = getModelClassName(ctx);
|
|
57
|
+
return getRunJSScenesForModel(modelClass, version);
|
|
58
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
// 为避免在模块初始化阶段引入 FlowContext(从而触发循环依赖),不要在顶层导入各类 RunJSContext。
|
|
11
|
+
// 在需要默认映射时(首次 resolve)再使用 createRequire 同步加载对应模块。
|
|
12
|
+
|
|
13
|
+
export type RunJSVersion = 'v1' | (string & {});
|
|
14
|
+
export type RunJSContextCtor = new (delegate: any) => any;
|
|
15
|
+
export type RunJSContextMeta = {
|
|
16
|
+
scenes?: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export class RunJSContextRegistry {
|
|
20
|
+
private static map = new Map<string, { ctor: RunJSContextCtor; meta?: RunJSContextMeta }>();
|
|
21
|
+
static register(version: RunJSVersion, modelClass: string, ctor: RunJSContextCtor, meta?: RunJSContextMeta) {
|
|
22
|
+
this.map.set(`${version}:${modelClass}`, { ctor, meta });
|
|
23
|
+
}
|
|
24
|
+
static resolve(version: RunJSVersion, modelClass: string) {
|
|
25
|
+
return this.map.get(`${version}:${modelClass}`)?.ctor || this.map.get(`${version}:*`)?.ctor;
|
|
26
|
+
}
|
|
27
|
+
static getMeta(version: RunJSVersion, modelClass: string): RunJSContextMeta | undefined {
|
|
28
|
+
return this.map.get(`${version}:${modelClass}`)?.meta || this.map.get(`${version}:*`)?.meta;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getModelClassName(ctx: any): string {
|
|
33
|
+
return ctx?.model?.constructor?.name || '*';
|
|
34
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* RunJS context registration entry. No side-effects by default.
|
|
12
|
+
*/
|
|
13
|
+
import { RunJSContextRegistry } from './registry';
|
|
14
|
+
import { FlowRunJSContext } from '../flowContext';
|
|
15
|
+
import { defineBaseContextMeta } from './contexts/base';
|
|
16
|
+
|
|
17
|
+
let done = false;
|
|
18
|
+
export async function setupRunJSContexts() {
|
|
19
|
+
if (done) return;
|
|
20
|
+
defineBaseContextMeta();
|
|
21
|
+
|
|
22
|
+
// Lazy import to avoid circular dependencies during module initialization
|
|
23
|
+
const [
|
|
24
|
+
{ JSBlockRunJSContext },
|
|
25
|
+
{ JSFieldRunJSContext },
|
|
26
|
+
{ JSItemRunJSContext },
|
|
27
|
+
{ JSColumnRunJSContext },
|
|
28
|
+
{ FormJSFieldItemRunJSContext },
|
|
29
|
+
{ JSRecordActionRunJSContext },
|
|
30
|
+
{ JSCollectionActionRunJSContext },
|
|
31
|
+
] = await Promise.all([
|
|
32
|
+
import('./contexts/JSBlockRunJSContext'),
|
|
33
|
+
import('./contexts/JSFieldRunJSContext'),
|
|
34
|
+
import('./contexts/JSItemRunJSContext'),
|
|
35
|
+
import('./contexts/JSColumnRunJSContext'),
|
|
36
|
+
import('./contexts/FormJSFieldItemRunJSContext'),
|
|
37
|
+
import('./contexts/JSRecordActionRunJSContext'),
|
|
38
|
+
import('./contexts/JSCollectionActionRunJSContext'),
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
const v1 = 'v1';
|
|
42
|
+
RunJSContextRegistry.register(v1, '*', FlowRunJSContext);
|
|
43
|
+
RunJSContextRegistry.register(v1, 'JSBlockModel', JSBlockRunJSContext, { scenes: ['block'] });
|
|
44
|
+
RunJSContextRegistry.register(v1, 'JSFieldModel', JSFieldRunJSContext, { scenes: ['detail'] });
|
|
45
|
+
RunJSContextRegistry.register(v1, 'JSItemModel', JSItemRunJSContext, { scenes: ['form'] });
|
|
46
|
+
RunJSContextRegistry.register(v1, 'JSColumnModel', JSColumnRunJSContext, { scenes: ['table'] });
|
|
47
|
+
RunJSContextRegistry.register(v1, 'FormJSFieldItemModel', FormJSFieldItemRunJSContext, { scenes: ['form'] });
|
|
48
|
+
RunJSContextRegistry.register(v1, 'JSRecordActionModel', JSRecordActionRunJSContext, { scenes: ['table'] });
|
|
49
|
+
RunJSContextRegistry.register(v1, 'JSCollectionActionModel', JSCollectionActionRunJSContext, { scenes: ['table'] });
|
|
50
|
+
done = true;
|
|
51
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
import type { SnippetModule } from '../types';
|
|
11
|
+
|
|
12
|
+
const snippet: SnippetModule = {
|
|
13
|
+
contexts: ['*'],
|
|
14
|
+
prefix: 'sn-api-request',
|
|
15
|
+
label: 'API request template',
|
|
16
|
+
description: 'Basic template to send HTTP requests via ctx.api.request',
|
|
17
|
+
locales: {
|
|
18
|
+
'zh-CN': {
|
|
19
|
+
label: 'API 请求模板',
|
|
20
|
+
description: '使用 ctx.api.request 发送 HTTP 请求的基础模板',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
content: `
|
|
24
|
+
// Replace url/method/params/data as needed
|
|
25
|
+
const response = await ctx.api.request({
|
|
26
|
+
url: 'users:list',
|
|
27
|
+
method: 'get',
|
|
28
|
+
params: {
|
|
29
|
+
pageSize: 10,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
ctx.message.success(ctx.t('Request finished'));
|
|
34
|
+
console.log(ctx.t('Response data:'), response?.data);
|
|
35
|
+
`,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default snippet;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import type { SnippetModule } from '../types';
|
|
11
|
+
|
|
12
|
+
const snippet: SnippetModule = {
|
|
13
|
+
contexts: ['*'],
|
|
14
|
+
prefix: 'sn-import',
|
|
15
|
+
label: 'Import ESM module',
|
|
16
|
+
description: 'Dynamically import an ESM module by URL',
|
|
17
|
+
locales: {
|
|
18
|
+
'zh-CN': {
|
|
19
|
+
label: '导入 ESM 模块',
|
|
20
|
+
description: '按 URL 动态导入 ESM 模块',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
content: `
|
|
24
|
+
// Import an ESM module by URL
|
|
25
|
+
// Works in yarn dev and yarn start
|
|
26
|
+
const mod = await ctx.importAsync('https://cdn.jsdelivr.net/npm/lit-html@2/+esm');
|
|
27
|
+
const { html, render } = mod;
|
|
28
|
+
|
|
29
|
+
ctx.element.innerHTML = '';
|
|
30
|
+
const container = document.createElement('div');
|
|
31
|
+
container.style.padding = '8px';
|
|
32
|
+
container.style.border = '1px dashed #999';
|
|
33
|
+
ctx.element.append(container);
|
|
34
|
+
|
|
35
|
+
render(html\`<span style="color:#52c41a;">lit-html loaded and rendered</span>\`, container);
|
|
36
|
+
`,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default snippet;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import type { SnippetModule } from '../types';
|
|
11
|
+
const snippet: SnippetModule = {
|
|
12
|
+
contexts: ['*'],
|
|
13
|
+
prefix: 'sn-msg-error',
|
|
14
|
+
label: 'Message error',
|
|
15
|
+
description: 'Show an error toast message',
|
|
16
|
+
locales: {
|
|
17
|
+
'zh-CN': {
|
|
18
|
+
label: '错误消息提示',
|
|
19
|
+
description: '显示一条错误提示消息',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
content: `
|
|
23
|
+
ctx.message.error(ctx.t('Operation failed'));
|
|
24
|
+
`,
|
|
25
|
+
};
|
|
26
|
+
export default snippet;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import type { SnippetModule } from '../types';
|
|
11
|
+
const snippet: SnippetModule = {
|
|
12
|
+
contexts: ['*'],
|
|
13
|
+
prefix: 'sn-msg',
|
|
14
|
+
label: 'Message success',
|
|
15
|
+
description: 'Show a success toast message',
|
|
16
|
+
locales: {
|
|
17
|
+
'zh-CN': {
|
|
18
|
+
label: '成功消息提示',
|
|
19
|
+
description: '显示一条成功提示消息',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
content: `
|
|
23
|
+
ctx.message.success(ctx.t('Operation succeeded'));
|
|
24
|
+
`,
|
|
25
|
+
};
|
|
26
|
+
export default snippet;
|