@nocobase/flow-engine 2.0.0-beta.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BlockScopedFlowEngine.js +0 -1
- package/lib/FlowDefinition.d.ts +2 -0
- package/lib/JSRunner.d.ts +6 -0
- package/lib/JSRunner.js +32 -2
- package/lib/ViewScopedFlowEngine.js +3 -0
- package/lib/acl/Acl.js +13 -3
- package/lib/components/FlowContextSelector.js +155 -10
- package/lib/components/settings/wrappers/component/SwitchWithTitle.js +2 -1
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -15
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +24 -4
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +5 -1
- package/lib/components/variables/VariableInput.js +9 -4
- package/lib/components/variables/VariableTag.js +46 -39
- package/lib/components/variables/utils.d.ts +7 -0
- package/lib/components/variables/utils.js +42 -2
- package/lib/data-source/index.d.ts +7 -27
- package/lib/data-source/index.js +81 -51
- package/lib/executor/FlowExecutor.d.ts +2 -1
- package/lib/executor/FlowExecutor.js +163 -22
- package/lib/flowContext.d.ts +230 -7
- package/lib/flowContext.js +2267 -148
- package/lib/flowEngine.d.ts +21 -0
- package/lib/flowEngine.js +56 -8
- package/lib/flowI18n.js +6 -4
- package/lib/flowSettings.js +17 -11
- package/lib/index.d.ts +7 -1
- package/lib/index.js +21 -0
- package/lib/locale/en-US.json +9 -2
- package/lib/locale/index.d.ts +14 -0
- package/lib/locale/zh-CN.json +8 -1
- package/lib/models/CollectionFieldModel.d.ts +1 -0
- package/lib/models/CollectionFieldModel.js +3 -2
- package/lib/models/flowModel.js +12 -1
- package/lib/provider.js +5 -5
- package/lib/resources/baseRecordResource.d.ts +5 -0
- package/lib/resources/baseRecordResource.js +24 -0
- package/lib/resources/multiRecordResource.d.ts +1 -0
- package/lib/resources/multiRecordResource.js +11 -4
- package/lib/resources/singleRecordResource.js +2 -0
- package/lib/resources/sqlResource.d.ts +4 -3
- package/lib/resources/sqlResource.js +8 -3
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +2 -2
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +125 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/base.js +706 -41
- package/lib/runjs-context/contributions.d.ts +33 -0
- package/lib/runjs-context/contributions.js +88 -0
- package/lib/runjs-context/helpers.js +12 -1
- package/lib/runjs-context/setup.js +6 -0
- package/lib/runjs-context/snippets/global/api-request.snippet.js +3 -3
- package/lib/runjs-context/snippets/global/import-esm.snippet.js +2 -3
- package/lib/runjs-context/snippets/global/query-selector.snippet.js +8 -3
- package/lib/runjs-context/snippets/global/require-amd.snippet.js +1 -1
- package/lib/runjs-context/snippets/index.d.ts +11 -1
- package/lib/runjs-context/snippets/index.js +61 -40
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +10 -7
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +5 -5
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +6 -6
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +3 -4
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +20 -3
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +6 -3
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +3 -1
- package/lib/runjsLibs.d.ts +28 -0
- package/lib/runjsLibs.js +532 -0
- package/lib/scheduler/ModelOperationScheduler.d.ts +2 -0
- package/lib/scheduler/ModelOperationScheduler.js +25 -21
- package/lib/types.d.ts +27 -0
- package/lib/utils/associationObjectVariable.d.ts +2 -2
- package/lib/utils/createCollectionContextMeta.js +1 -0
- package/lib/utils/createEphemeralContext.js +2 -2
- package/lib/utils/dateVariable.d.ts +16 -0
- package/lib/utils/dateVariable.js +380 -0
- package/lib/utils/exceptions.d.ts +7 -0
- package/lib/utils/exceptions.js +10 -0
- package/lib/utils/index.d.ts +8 -3
- package/lib/utils/index.js +45 -0
- package/lib/utils/params-resolvers.js +16 -9
- package/lib/utils/resolveModuleUrl.d.ts +58 -0
- package/lib/utils/resolveModuleUrl.js +65 -0
- package/lib/utils/resolveRunJSObjectValues.d.ts +16 -0
- package/lib/utils/resolveRunJSObjectValues.js +61 -0
- package/lib/utils/runjsModuleLoader.d.ts +58 -0
- package/lib/utils/runjsModuleLoader.js +422 -0
- package/lib/utils/runjsTemplateCompat.d.ts +35 -0
- package/lib/utils/runjsTemplateCompat.js +743 -0
- package/lib/utils/runjsValue.d.ts +29 -0
- package/lib/utils/runjsValue.js +275 -0
- package/lib/utils/safeGlobals.d.ts +18 -8
- package/lib/utils/safeGlobals.js +164 -17
- package/lib/utils/schema-utils.d.ts +10 -0
- package/lib/utils/schema-utils.js +61 -0
- package/lib/views/createViewMeta.d.ts +0 -7
- package/lib/views/createViewMeta.js +19 -70
- package/lib/views/index.d.ts +1 -2
- package/lib/views/index.js +4 -3
- package/lib/views/useDialog.js +7 -2
- package/lib/views/useDrawer.js +7 -2
- package/lib/views/usePage.d.ts +4 -0
- package/lib/views/usePage.js +43 -6
- package/lib/views/usePopover.js +4 -1
- package/lib/views/viewEvents.d.ts +17 -0
- package/lib/views/viewEvents.js +90 -0
- package/package.json +4 -4
- package/src/BlockScopedFlowEngine.ts +2 -5
- package/src/JSRunner.ts +44 -2
- package/src/ViewScopedFlowEngine.ts +4 -0
- package/src/__tests__/JSRunner.test.ts +64 -0
- package/src/__tests__/createViewMeta.popup.test.ts +62 -1
- package/src/__tests__/flowContext.test.ts +693 -1
- package/src/__tests__/flowEngine.dataSourceDirty.test.ts +63 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +28 -0
- package/src/__tests__/flowRunJSContextDefine.test.ts +63 -0
- package/src/__tests__/flowRuntimeContext.test.ts +2 -1
- package/src/__tests__/flowSettings.open.test.tsx +123 -19
- package/src/__tests__/runjsContext.test.ts +10 -7
- package/src/__tests__/runjsContextImplementations.test.ts +34 -3
- package/src/__tests__/runjsContextRuntime.test.ts +3 -3
- package/src/__tests__/runjsContributions.test.ts +89 -0
- package/src/__tests__/runjsExternalLibs.test.ts +242 -0
- package/src/__tests__/runjsLibsLazyLoading.test.ts +44 -0
- package/src/__tests__/runjsLocales.test.ts +4 -1
- package/src/__tests__/runjsPreprocessDefault.test.ts +49 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +166 -0
- package/src/__tests__/runjsSnippets.test.ts +40 -3
- package/src/acl/Acl.tsx +3 -3
- package/src/components/FlowContextSelector.tsx +208 -12
- package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +2 -1
- package/src/components/settings/wrappers/component/__tests__/InlineControls.test.tsx +74 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +109 -16
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +41 -7
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +13 -2
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +157 -5
- package/src/components/variables/VariableInput.tsx +12 -4
- package/src/components/variables/VariableTag.tsx +54 -45
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +260 -3
- package/src/components/variables/__tests__/VariableTag.test.tsx +50 -0
- package/src/components/variables/__tests__/utils.test.ts +81 -3
- package/src/components/variables/utils.ts +67 -6
- package/src/data-source/index.ts +85 -110
- package/src/executor/FlowExecutor.ts +200 -23
- package/src/executor/__tests__/flowExecutor.test.ts +66 -0
- package/src/flowContext.ts +2986 -211
- package/src/flowEngine.ts +59 -8
- package/src/flowI18n.ts +7 -5
- package/src/flowSettings.ts +18 -12
- package/src/index.ts +14 -1
- package/src/locale/en-US.json +9 -2
- package/src/locale/zh-CN.json +8 -1
- package/src/models/CollectionFieldModel.tsx +3 -1
- package/src/models/__tests__/dispatchEvent.when.test.ts +554 -0
- package/src/models/__tests__/flowModel.test.ts +20 -4
- package/src/models/flowModel.tsx +13 -1
- package/src/provider.tsx +7 -6
- package/src/resources/__tests__/multiRecordResource.test.ts +44 -0
- package/src/resources/__tests__/sqlResource.test.ts +60 -0
- package/src/resources/baseRecordResource.ts +31 -0
- package/src/resources/multiRecordResource.ts +11 -4
- package/src/resources/singleRecordResource.ts +3 -0
- package/src/resources/sqlResource.ts +11 -6
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +6 -2
- package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +106 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/base.ts +715 -44
- package/src/runjs-context/contributions.ts +88 -0
- package/src/runjs-context/helpers.ts +11 -1
- package/src/runjs-context/setup.ts +6 -0
- package/src/runjs-context/snippets/global/api-request.snippet.ts +3 -3
- package/src/runjs-context/snippets/global/import-esm.snippet.ts +2 -3
- package/src/runjs-context/snippets/global/query-selector.snippet.ts +8 -3
- package/src/runjs-context/snippets/global/require-amd.snippet.ts +1 -1
- package/src/runjs-context/snippets/index.ts +75 -41
- package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +11 -13
- package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +6 -11
- package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +6 -6
- package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +3 -4
- package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +20 -3
- package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +3 -8
- package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +6 -3
- package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +3 -1
- package/src/runjsLibs.ts +622 -0
- package/src/scheduler/ModelOperationScheduler.ts +27 -21
- package/src/types.ts +38 -1
- package/src/utils/__tests__/dateVariable.test.ts +101 -0
- package/src/utils/__tests__/params-resolvers.test.ts +40 -0
- package/src/utils/__tests__/runjsRequireAsyncAutoWhitelist.test.ts +38 -0
- package/src/utils/__tests__/runjsTemplateCompat.test.ts +159 -0
- package/src/utils/__tests__/runjsValue.test.ts +44 -0
- package/src/utils/__tests__/safeGlobals.test.ts +57 -2
- package/src/utils/__tests__/utils.test.ts +95 -0
- package/src/utils/associationObjectVariable.ts +2 -2
- package/src/utils/createCollectionContextMeta.ts +1 -0
- package/src/utils/createEphemeralContext.ts +5 -4
- package/src/utils/dateVariable.ts +397 -0
- package/src/utils/exceptions.ts +11 -0
- package/src/utils/index.ts +37 -3
- package/src/utils/params-resolvers.ts +23 -9
- package/src/utils/resolveModuleUrl.ts +91 -0
- package/src/utils/resolveRunJSObjectValues.ts +46 -0
- package/src/utils/runjsModuleLoader.ts +553 -0
- package/src/utils/runjsTemplateCompat.ts +828 -0
- package/src/utils/runjsValue.ts +287 -0
- package/src/utils/safeGlobals.ts +188 -17
- package/src/utils/schema-utils.ts +79 -0
- package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +35 -8
- package/src/views/__tests__/viewEvents.resolveOpenerEngine.test.ts +28 -0
- package/src/views/createViewMeta.ts +22 -75
- package/src/views/index.tsx +1 -2
- package/src/views/useDialog.tsx +8 -1
- package/src/views/useDrawer.tsx +8 -1
- package/src/views/usePage.tsx +51 -5
- package/src/views/usePopover.tsx +4 -1
- package/src/views/viewEvents.ts +55 -0
package/lib/types.d.ts
CHANGED
|
@@ -147,6 +147,18 @@ export interface ActionDefinition<TModel extends FlowModel = FlowModel, TCtx ext
|
|
|
147
147
|
* - StepDefinition.hideInSettings can override the ActionDefinition value.
|
|
148
148
|
*/
|
|
149
149
|
hideInSettings?: boolean | ((ctx: TCtx) => boolean | Promise<boolean>);
|
|
150
|
+
/**
|
|
151
|
+
* Whether to disable this step/action in settings menus.
|
|
152
|
+
* - Supports static boolean and dynamic decision based on runtime context.
|
|
153
|
+
* - StepDefinition.disabledInSettings can override the ActionDefinition value.
|
|
154
|
+
*/
|
|
155
|
+
disabledInSettings?: boolean | ((ctx: TCtx) => boolean | Promise<boolean>);
|
|
156
|
+
/**
|
|
157
|
+
* Optional reason shown when this step/action is disabled in settings menus.
|
|
158
|
+
* - Supports static string and dynamic resolver based on runtime context.
|
|
159
|
+
* - StepDefinition.disabledReasonInSettings can override the ActionDefinition value.
|
|
160
|
+
*/
|
|
161
|
+
disabledReasonInSettings?: string | ((ctx: TCtx) => string | Promise<string>);
|
|
150
162
|
/**
|
|
151
163
|
* 在执行 Action 前为 ctx 定义临时属性。
|
|
152
164
|
* - 仅支持 PropertyOptions 形态(例如:{ foo: { value: 5 } });
|
|
@@ -166,12 +178,27 @@ export interface ActionDefinition<TModel extends FlowModel = FlowModel, TCtx ext
|
|
|
166
178
|
* - 允许扩展字符串以保持向后兼容。
|
|
167
179
|
*/
|
|
168
180
|
export type FlowEventName = 'click' | 'submit' | 'reset' | 'remove' | 'openView' | 'dropdownOpen' | 'popupScroll' | 'search' | 'customRequest' | 'collapseToggle' | (string & {});
|
|
181
|
+
/**
|
|
182
|
+
* 事件流的执行时机(phase)。
|
|
183
|
+
*
|
|
184
|
+
* 说明:
|
|
185
|
+
* - 缺省(phase 未配置)表示保持现有行为;
|
|
186
|
+
* - 当配置了 phase 时,运行时会将其映射为 `scheduleModelOperation` 的 `when` 锚点;
|
|
187
|
+
* - phase 同时适用于动态事件流(实例级)与静态流(内置)。
|
|
188
|
+
*/
|
|
189
|
+
export type FlowEventPhase = 'beforeAllFlows' | 'afterAllFlows' | 'beforeFlow' | 'afterFlow' | 'beforeStep' | 'afterStep';
|
|
169
190
|
/**
|
|
170
191
|
* Flow 事件类型(供 FlowDefinitionOptions.on 使用)。
|
|
171
192
|
*/
|
|
172
193
|
export type FlowEvent<TModel extends FlowModel = FlowModel> = FlowEventName | {
|
|
173
194
|
eventName: FlowEventName;
|
|
174
195
|
defaultParams?: Record<string, any>;
|
|
196
|
+
/** 动态事件流的执行时机(默认 beforeAllFlows) */
|
|
197
|
+
phase?: FlowEventPhase;
|
|
198
|
+
/** phase 为 beforeFlow/afterFlow/beforeStep/afterStep 时使用 */
|
|
199
|
+
flowKey?: string;
|
|
200
|
+
/** phase 为 beforeStep/afterStep 时使用 */
|
|
201
|
+
stepKey?: string;
|
|
175
202
|
};
|
|
176
203
|
/**
|
|
177
204
|
* 事件分发选项。
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { Collection } from '../data-source';
|
|
10
10
|
import type { FlowContext, PropertyMetaFactory } from '../flowContext';
|
|
11
11
|
/**
|
|
12
|
-
* 创建一个用于“对象类变量”(如 formValues /
|
|
12
|
+
* 创建一个用于“对象类变量”(如 formValues / item)的 `resolveOnServer` 判定函数。
|
|
13
13
|
* 仅当访问路径以“关联字段名”开头(且继续访问其子属性)时,返回 true 交由服务端解析;
|
|
14
14
|
* 否则在前端解析即可。
|
|
15
15
|
*
|
|
@@ -26,7 +26,7 @@ export declare function createAssociationSubpathResolver(collectionAccessor: ()
|
|
|
26
26
|
*
|
|
27
27
|
* @param collectionAccessor 获取集合对象,用于字段/元信息来源
|
|
28
28
|
* @param title 变量组标题(用于 UI 展示)
|
|
29
|
-
* @param valueAccessor 获取当前对象值(如 ctx.form.getFieldsValue() / ctx.
|
|
29
|
+
* @param valueAccessor 获取当前对象值(如 ctx.form.getFieldsValue() / ctx.item)
|
|
30
30
|
* @returns PropertyMetaFactory
|
|
31
31
|
*/
|
|
32
32
|
export declare function createAssociationAwareObjectMetaFactory(collectionAccessor: () => Collection | null, title: string, valueAccessor: (ctx: FlowContext) => any): PropertyMetaFactory;
|
|
@@ -52,7 +52,7 @@ async function createEphemeralContext(parent, contextDefs) {
|
|
|
52
52
|
return (propKey, options) => scoped.defineProperty(propKey, options);
|
|
53
53
|
}
|
|
54
54
|
if (key === "defineMethod") {
|
|
55
|
-
return (name, fn,
|
|
55
|
+
return (name, fn, info) => scoped.defineMethod(name, fn, info);
|
|
56
56
|
}
|
|
57
57
|
if (Reflect.has(scopedObj, key)) {
|
|
58
58
|
return Reflect.get(scopedObj, key, receiver);
|
|
@@ -112,7 +112,7 @@ async function createEphemeralContext(parent, contextDefs) {
|
|
|
112
112
|
return (propKey, options) => parent.defineProperty(propKey, options);
|
|
113
113
|
}
|
|
114
114
|
if (key === "defineMethod") {
|
|
115
|
-
return (name, fn,
|
|
115
|
+
return (name, fn, info) => parent.defineMethod(name, fn, info);
|
|
116
116
|
}
|
|
117
117
|
if (Reflect.has(scopedObj, key)) {
|
|
118
118
|
return Reflect.get(scopedObj, key, receiver);
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export declare function isCtxDatePathPrefix(pathSegments: string[]): boolean;
|
|
10
|
+
export declare function encodeBase64Url(input: string): string;
|
|
11
|
+
export declare function decodeBase64Url(input: string): string | undefined;
|
|
12
|
+
export declare function isCtxDateExpression(value: unknown): value is string;
|
|
13
|
+
export declare function isCompleteCtxDatePath(pathSegments: string[]): boolean;
|
|
14
|
+
export declare function parseCtxDateExpression(value: unknown): any;
|
|
15
|
+
export declare function serializeCtxDateValue(value: unknown): string | undefined;
|
|
16
|
+
export declare function resolveCtxDatePath(pathSegments: string[]): any;
|
|
@@ -0,0 +1,380 @@
|
|
|
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 dateVariable_exports = {};
|
|
39
|
+
__export(dateVariable_exports, {
|
|
40
|
+
decodeBase64Url: () => decodeBase64Url,
|
|
41
|
+
encodeBase64Url: () => encodeBase64Url,
|
|
42
|
+
isCompleteCtxDatePath: () => isCompleteCtxDatePath,
|
|
43
|
+
isCtxDateExpression: () => isCtxDateExpression,
|
|
44
|
+
isCtxDatePathPrefix: () => isCtxDatePathPrefix,
|
|
45
|
+
parseCtxDateExpression: () => parseCtxDateExpression,
|
|
46
|
+
resolveCtxDatePath: () => resolveCtxDatePath,
|
|
47
|
+
serializeCtxDateValue: () => serializeCtxDateValue
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(dateVariable_exports);
|
|
50
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
51
|
+
const CTX_DATE_REGEX = /^\{\{\s*ctx\.date(?:\.(.+?))?\s*\}\}$/;
|
|
52
|
+
const PRESET_KEYS = /* @__PURE__ */ new Set([
|
|
53
|
+
"today",
|
|
54
|
+
"now",
|
|
55
|
+
"yesterday",
|
|
56
|
+
"tomorrow",
|
|
57
|
+
"thisWeek",
|
|
58
|
+
"lastWeek",
|
|
59
|
+
"nextWeek",
|
|
60
|
+
"thisMonth",
|
|
61
|
+
"lastMonth",
|
|
62
|
+
"nextMonth",
|
|
63
|
+
"thisQuarter",
|
|
64
|
+
"lastQuarter",
|
|
65
|
+
"nextQuarter",
|
|
66
|
+
"thisYear",
|
|
67
|
+
"lastYear",
|
|
68
|
+
"nextYear"
|
|
69
|
+
]);
|
|
70
|
+
const RELATIVE_DIRECTIONS = /* @__PURE__ */ new Set(["next", "past"]);
|
|
71
|
+
const RELATIVE_UNITS = /* @__PURE__ */ new Set(["day", "week", "month", "year"]);
|
|
72
|
+
function parseCtxDateSegments(value) {
|
|
73
|
+
if (typeof value !== "string") return null;
|
|
74
|
+
const trimmed = value.trim();
|
|
75
|
+
const match = trimmed.match(CTX_DATE_REGEX);
|
|
76
|
+
if (!match) return null;
|
|
77
|
+
const rawPath = String(match[1] || "");
|
|
78
|
+
if (!rawPath) return [];
|
|
79
|
+
return rawPath.split(".").map((seg) => seg.trim()).filter(Boolean);
|
|
80
|
+
}
|
|
81
|
+
__name(parseCtxDateSegments, "parseCtxDateSegments");
|
|
82
|
+
function isCtxDatePathPrefix(pathSegments) {
|
|
83
|
+
const segments = withDatePrefix((pathSegments || []).map((seg) => String(seg)));
|
|
84
|
+
if (segments[0] !== "date") return false;
|
|
85
|
+
if (segments.length === 1) return true;
|
|
86
|
+
if (segments[1] === "preset") {
|
|
87
|
+
if (segments.length === 2) return true;
|
|
88
|
+
return segments.length === 3 && PRESET_KEYS.has(segments[2]);
|
|
89
|
+
}
|
|
90
|
+
if (segments[1] === "relative") {
|
|
91
|
+
if (segments.length === 2) return true;
|
|
92
|
+
if (segments.length === 3) return RELATIVE_DIRECTIONS.has(segments[2]);
|
|
93
|
+
if (segments.length === 4) {
|
|
94
|
+
return RELATIVE_DIRECTIONS.has(segments[2]) && RELATIVE_UNITS.has(segments[3]);
|
|
95
|
+
}
|
|
96
|
+
if (segments.length === 5) {
|
|
97
|
+
return RELATIVE_DIRECTIONS.has(segments[2]) && RELATIVE_UNITS.has(segments[3]) && typeof parseNumberToken(segments[4]) === "number";
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (segments[1] === "exact") {
|
|
102
|
+
if (segments.length === 2) return true;
|
|
103
|
+
if (segments[2] === "single") {
|
|
104
|
+
if (segments.length === 3) return true;
|
|
105
|
+
if (segments.length === 4) return segments[3] === "date";
|
|
106
|
+
if (segments.length === 5) return segments[3] === "date" && /^v.+/.test(segments[4]);
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
if (segments[2] === "range") {
|
|
110
|
+
if (segments.length === 3) return true;
|
|
111
|
+
if (segments.length === 4) return segments[3] === "date";
|
|
112
|
+
if (segments.length === 5) return segments[3] === "date" && /^v.+/.test(segments[4]);
|
|
113
|
+
if (segments.length === 6) return segments[3] === "date" && /^v.+/.test(segments[4]) && /^v.+/.test(segments[5]);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
__name(isCtxDatePathPrefix, "isCtxDatePathPrefix");
|
|
121
|
+
function withDatePrefix(pathSegments) {
|
|
122
|
+
if (pathSegments[0] === "date") {
|
|
123
|
+
return pathSegments;
|
|
124
|
+
}
|
|
125
|
+
return ["date", ...pathSegments];
|
|
126
|
+
}
|
|
127
|
+
__name(withDatePrefix, "withDatePrefix");
|
|
128
|
+
function toCtxDateExpression(pathSegments) {
|
|
129
|
+
const segs = withDatePrefix(pathSegments);
|
|
130
|
+
return `{{ ctx.${segs.join(".")} }}`;
|
|
131
|
+
}
|
|
132
|
+
__name(toCtxDateExpression, "toCtxDateExpression");
|
|
133
|
+
function utf8ToBase64(input) {
|
|
134
|
+
const globalBuffer = globalThis == null ? void 0 : globalThis.Buffer;
|
|
135
|
+
if (globalBuffer && typeof globalBuffer.from === "function") {
|
|
136
|
+
return globalBuffer.from(input, "utf8").toString("base64");
|
|
137
|
+
}
|
|
138
|
+
if (typeof btoa === "function") {
|
|
139
|
+
const encoded = encodeURIComponent(input).replace(
|
|
140
|
+
/%([0-9A-F]{2})/g,
|
|
141
|
+
(_m, p1) => String.fromCharCode(parseInt(p1, 16))
|
|
142
|
+
);
|
|
143
|
+
return btoa(encoded);
|
|
144
|
+
}
|
|
145
|
+
throw new Error("No base64 encoder available");
|
|
146
|
+
}
|
|
147
|
+
__name(utf8ToBase64, "utf8ToBase64");
|
|
148
|
+
function base64ToUtf8(input) {
|
|
149
|
+
const globalBuffer = globalThis == null ? void 0 : globalThis.Buffer;
|
|
150
|
+
if (globalBuffer && typeof globalBuffer.from === "function") {
|
|
151
|
+
return globalBuffer.from(input, "base64").toString("utf8");
|
|
152
|
+
}
|
|
153
|
+
if (typeof atob === "function") {
|
|
154
|
+
const binary = atob(input);
|
|
155
|
+
const encoded = Array.from(binary).map((char) => `%${char.charCodeAt(0).toString(16).padStart(2, "0")}`).join("");
|
|
156
|
+
return decodeURIComponent(encoded);
|
|
157
|
+
}
|
|
158
|
+
throw new Error("No base64 decoder available");
|
|
159
|
+
}
|
|
160
|
+
__name(base64ToUtf8, "base64ToUtf8");
|
|
161
|
+
function normalizeToString(value) {
|
|
162
|
+
if (value == null) return void 0;
|
|
163
|
+
if (typeof value === "string") {
|
|
164
|
+
const trimmed = value.trim();
|
|
165
|
+
return trimmed.length ? trimmed : void 0;
|
|
166
|
+
}
|
|
167
|
+
if (import_dayjs.default.isDayjs(value)) {
|
|
168
|
+
return value.toISOString();
|
|
169
|
+
}
|
|
170
|
+
if (value instanceof Date) {
|
|
171
|
+
return (0, import_dayjs.default)(value).toISOString();
|
|
172
|
+
}
|
|
173
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
174
|
+
return String(value);
|
|
175
|
+
}
|
|
176
|
+
return void 0;
|
|
177
|
+
}
|
|
178
|
+
__name(normalizeToString, "normalizeToString");
|
|
179
|
+
function parseNumberToken(token) {
|
|
180
|
+
const match = String(token || "").match(/^n(\d+)$/);
|
|
181
|
+
if (!match) return void 0;
|
|
182
|
+
const parsed = Number(match[1]);
|
|
183
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return void 0;
|
|
184
|
+
return parsed;
|
|
185
|
+
}
|
|
186
|
+
__name(parseNumberToken, "parseNumberToken");
|
|
187
|
+
function startOfIsoWeek(date) {
|
|
188
|
+
const day = date.day();
|
|
189
|
+
const offset = day === 0 ? -6 : 1 - day;
|
|
190
|
+
return date.add(offset, "day").startOf("day");
|
|
191
|
+
}
|
|
192
|
+
__name(startOfIsoWeek, "startOfIsoWeek");
|
|
193
|
+
function startOfQuarter(date) {
|
|
194
|
+
const month = date.month();
|
|
195
|
+
const quarterStartMonth = Math.floor(month / 3) * 3;
|
|
196
|
+
return date.month(quarterStartMonth).startOf("month");
|
|
197
|
+
}
|
|
198
|
+
__name(startOfQuarter, "startOfQuarter");
|
|
199
|
+
function encodeBase64Url(input) {
|
|
200
|
+
const base64 = utf8ToBase64(String(input || ""));
|
|
201
|
+
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
202
|
+
}
|
|
203
|
+
__name(encodeBase64Url, "encodeBase64Url");
|
|
204
|
+
function decodeBase64Url(input) {
|
|
205
|
+
try {
|
|
206
|
+
const raw = String(input || "").replace(/=+$/g, "");
|
|
207
|
+
if (!raw) return void 0;
|
|
208
|
+
if (!/^[A-Za-z0-9_-]+$/.test(raw)) return void 0;
|
|
209
|
+
const normalized = raw.replace(/-/g, "+").replace(/_/g, "/");
|
|
210
|
+
const padLength = normalized.length % 4 === 0 ? 0 : 4 - normalized.length % 4;
|
|
211
|
+
const padded = `${normalized}${"=".repeat(padLength)}`;
|
|
212
|
+
const decoded = base64ToUtf8(padded);
|
|
213
|
+
if (encodeBase64Url(decoded) !== raw) return void 0;
|
|
214
|
+
return decoded;
|
|
215
|
+
} catch (_error) {
|
|
216
|
+
return void 0;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
__name(decodeBase64Url, "decodeBase64Url");
|
|
220
|
+
function isCtxDateExpression(value) {
|
|
221
|
+
if (typeof value !== "string") return false;
|
|
222
|
+
return CTX_DATE_REGEX.test(value.trim());
|
|
223
|
+
}
|
|
224
|
+
__name(isCtxDateExpression, "isCtxDateExpression");
|
|
225
|
+
function isCompleteCtxDatePath(pathSegments) {
|
|
226
|
+
if (!isCtxDatePathPrefix(pathSegments)) return false;
|
|
227
|
+
const segments = withDatePrefix((pathSegments || []).map((seg) => String(seg)));
|
|
228
|
+
if (segments[0] !== "date") return false;
|
|
229
|
+
if (segments[1] === "preset") {
|
|
230
|
+
return segments.length === 3 && PRESET_KEYS.has(segments[2]);
|
|
231
|
+
}
|
|
232
|
+
if (segments[1] === "relative") {
|
|
233
|
+
if (segments.length !== 5) return false;
|
|
234
|
+
return RELATIVE_DIRECTIONS.has(segments[2]) && RELATIVE_UNITS.has(segments[3]) && typeof parseNumberToken(segments[4]) === "number";
|
|
235
|
+
}
|
|
236
|
+
if (segments[1] === "exact" && segments[2] === "single" && segments[3] === "date") {
|
|
237
|
+
return segments.length === 5 && /^v.+/.test(segments[4]);
|
|
238
|
+
}
|
|
239
|
+
if (segments[1] === "exact" && segments[2] === "range" && segments[3] === "date") {
|
|
240
|
+
return segments.length === 6 && /^v.+/.test(segments[4]) && /^v.+/.test(segments[5]);
|
|
241
|
+
}
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
__name(isCompleteCtxDatePath, "isCompleteCtxDatePath");
|
|
245
|
+
function parseCtxDateExpression(value) {
|
|
246
|
+
if (!isCtxDateExpression(value)) return void 0;
|
|
247
|
+
const segments = withDatePrefix(parseCtxDateSegments(value) || []);
|
|
248
|
+
if (segments[1] === "preset" && segments.length === 3 && PRESET_KEYS.has(segments[2])) {
|
|
249
|
+
return { type: segments[2] };
|
|
250
|
+
}
|
|
251
|
+
if (segments[1] === "relative" && segments.length === 5 && RELATIVE_DIRECTIONS.has(segments[2]) && RELATIVE_UNITS.has(segments[3])) {
|
|
252
|
+
const amount = parseNumberToken(segments[4]);
|
|
253
|
+
if (typeof amount === "number") {
|
|
254
|
+
return { type: segments[2], unit: segments[3], number: amount };
|
|
255
|
+
}
|
|
256
|
+
return void 0;
|
|
257
|
+
}
|
|
258
|
+
if (segments[1] === "exact" && segments[2] === "single" && segments[3] === "date" && segments.length === 5) {
|
|
259
|
+
const raw = String(segments[4] || "");
|
|
260
|
+
if (!raw.startsWith("v")) return void 0;
|
|
261
|
+
return decodeBase64Url(raw.slice(1));
|
|
262
|
+
}
|
|
263
|
+
if (segments[1] === "exact" && segments[2] === "range" && segments[3] === "date" && segments.length === 6) {
|
|
264
|
+
const leftRaw = String(segments[4] || "");
|
|
265
|
+
const rightRaw = String(segments[5] || "");
|
|
266
|
+
if (!leftRaw.startsWith("v") || !rightRaw.startsWith("v")) return void 0;
|
|
267
|
+
const left = decodeBase64Url(leftRaw.slice(1));
|
|
268
|
+
const right = decodeBase64Url(rightRaw.slice(1));
|
|
269
|
+
if (typeof left === "undefined" || typeof right === "undefined") return void 0;
|
|
270
|
+
return [left, right];
|
|
271
|
+
}
|
|
272
|
+
return void 0;
|
|
273
|
+
}
|
|
274
|
+
__name(parseCtxDateExpression, "parseCtxDateExpression");
|
|
275
|
+
function serializeCtxDateValue(value) {
|
|
276
|
+
if (isCtxDateExpression(value)) {
|
|
277
|
+
return String(value).trim();
|
|
278
|
+
}
|
|
279
|
+
if (value == null || value === "") {
|
|
280
|
+
return void 0;
|
|
281
|
+
}
|
|
282
|
+
if (Array.isArray(value)) {
|
|
283
|
+
const start = normalizeToString(value[0]);
|
|
284
|
+
const end = normalizeToString(value[1]);
|
|
285
|
+
if (start && end) {
|
|
286
|
+
return toCtxDateExpression([
|
|
287
|
+
"date",
|
|
288
|
+
"exact",
|
|
289
|
+
"range",
|
|
290
|
+
"date",
|
|
291
|
+
`v${encodeBase64Url(start)}`,
|
|
292
|
+
`v${encodeBase64Url(end)}`
|
|
293
|
+
]);
|
|
294
|
+
}
|
|
295
|
+
if (start) {
|
|
296
|
+
return toCtxDateExpression(["date", "exact", "single", "date", `v${encodeBase64Url(start)}`]);
|
|
297
|
+
}
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
if (typeof value === "object" && value) {
|
|
301
|
+
const typed = value;
|
|
302
|
+
const type = typeof typed.type === "string" ? typed.type : "";
|
|
303
|
+
if (type === "past" || type === "next") {
|
|
304
|
+
const unit = typeof typed.unit === "string" && RELATIVE_UNITS.has(typed.unit) ? typed.unit : "day";
|
|
305
|
+
const rawNumber = Number(typed.number);
|
|
306
|
+
const number = Number.isFinite(rawNumber) && rawNumber > 0 ? Math.floor(rawNumber) : 1;
|
|
307
|
+
return toCtxDateExpression(["date", "relative", type, unit, `n${number}`]);
|
|
308
|
+
}
|
|
309
|
+
if (PRESET_KEYS.has(type)) {
|
|
310
|
+
return toCtxDateExpression(["date", "preset", type]);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const single = normalizeToString(value);
|
|
314
|
+
if (single) {
|
|
315
|
+
return toCtxDateExpression(["date", "exact", "single", "date", `v${encodeBase64Url(single)}`]);
|
|
316
|
+
}
|
|
317
|
+
return void 0;
|
|
318
|
+
}
|
|
319
|
+
__name(serializeCtxDateValue, "serializeCtxDateValue");
|
|
320
|
+
function resolveCtxDatePath(pathSegments) {
|
|
321
|
+
const segments = withDatePrefix((pathSegments || []).map((seg) => String(seg)));
|
|
322
|
+
if (segments[0] !== "date") return void 0;
|
|
323
|
+
if (segments[1] === "preset" && segments.length === 3) {
|
|
324
|
+
const key = segments[2];
|
|
325
|
+
if (key === "now") {
|
|
326
|
+
return (0, import_dayjs.default)().toISOString();
|
|
327
|
+
}
|
|
328
|
+
const now = (0, import_dayjs.default)();
|
|
329
|
+
if (key === "today") return now.format("YYYY-MM-DD");
|
|
330
|
+
if (key === "yesterday") return now.add(-1, "day").format("YYYY-MM-DD");
|
|
331
|
+
if (key === "tomorrow") return now.add(1, "day").format("YYYY-MM-DD");
|
|
332
|
+
if (key === "thisWeek") return startOfIsoWeek(now).format("YYYY-MM-DD");
|
|
333
|
+
if (key === "lastWeek") return startOfIsoWeek(now.add(-1, "week")).format("YYYY-MM-DD");
|
|
334
|
+
if (key === "nextWeek") return startOfIsoWeek(now.add(1, "week")).format("YYYY-MM-DD");
|
|
335
|
+
if (key === "thisMonth") return now.startOf("month").format("YYYY-MM-DD");
|
|
336
|
+
if (key === "lastMonth") return now.add(-1, "month").startOf("month").format("YYYY-MM-DD");
|
|
337
|
+
if (key === "nextMonth") return now.add(1, "month").startOf("month").format("YYYY-MM-DD");
|
|
338
|
+
if (key === "thisQuarter") return startOfQuarter(now).format("YYYY-MM-DD");
|
|
339
|
+
if (key === "lastQuarter") return startOfQuarter(now.add(-3, "month")).format("YYYY-MM-DD");
|
|
340
|
+
if (key === "nextQuarter") return startOfQuarter(now.add(3, "month")).format("YYYY-MM-DD");
|
|
341
|
+
if (key === "thisYear") return now.startOf("year").format("YYYY-MM-DD");
|
|
342
|
+
if (key === "lastYear") return now.add(-1, "year").startOf("year").format("YYYY-MM-DD");
|
|
343
|
+
if (key === "nextYear") return now.add(1, "year").startOf("year").format("YYYY-MM-DD");
|
|
344
|
+
return void 0;
|
|
345
|
+
}
|
|
346
|
+
if (segments[1] === "relative" && segments.length === 5 && RELATIVE_DIRECTIONS.has(segments[2]) && RELATIVE_UNITS.has(segments[3])) {
|
|
347
|
+
const amount = parseNumberToken(segments[4]);
|
|
348
|
+
if (typeof amount !== "number") return void 0;
|
|
349
|
+
const direction = segments[2] === "past" ? -1 : 1;
|
|
350
|
+
const unit = segments[3];
|
|
351
|
+
return (0, import_dayjs.default)().add(direction * amount, unit).format("YYYY-MM-DD");
|
|
352
|
+
}
|
|
353
|
+
if (segments[1] === "exact" && segments[2] === "single" && segments[3] === "date" && segments.length === 5) {
|
|
354
|
+
const token = String(segments[4] || "");
|
|
355
|
+
if (!token.startsWith("v")) return void 0;
|
|
356
|
+
return decodeBase64Url(token.slice(1));
|
|
357
|
+
}
|
|
358
|
+
if (segments[1] === "exact" && segments[2] === "range" && segments[3] === "date" && segments.length === 6) {
|
|
359
|
+
const leftToken = String(segments[4] || "");
|
|
360
|
+
const rightToken = String(segments[5] || "");
|
|
361
|
+
if (!leftToken.startsWith("v") || !rightToken.startsWith("v")) return void 0;
|
|
362
|
+
const left = decodeBase64Url(leftToken.slice(1));
|
|
363
|
+
const right = decodeBase64Url(rightToken.slice(1));
|
|
364
|
+
if (typeof left === "undefined" || typeof right === "undefined") return void 0;
|
|
365
|
+
return [left, right];
|
|
366
|
+
}
|
|
367
|
+
return void 0;
|
|
368
|
+
}
|
|
369
|
+
__name(resolveCtxDatePath, "resolveCtxDatePath");
|
|
370
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
371
|
+
0 && (module.exports = {
|
|
372
|
+
decodeBase64Url,
|
|
373
|
+
encodeBase64Url,
|
|
374
|
+
isCompleteCtxDatePath,
|
|
375
|
+
isCtxDateExpression,
|
|
376
|
+
isCtxDatePathPrefix,
|
|
377
|
+
parseCtxDateExpression,
|
|
378
|
+
resolveCtxDatePath,
|
|
379
|
+
serializeCtxDateValue
|
|
380
|
+
});
|
|
@@ -20,3 +20,10 @@ export declare class FlowExitAllException extends Error {
|
|
|
20
20
|
readonly modelUid: string;
|
|
21
21
|
constructor(flowKey: string, modelUid: string, message?: string);
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* 取消当前保存但保持设置弹窗打开
|
|
25
|
+
* 用于“保存前确认”场景,用户取消时不应关闭弹窗也不应提示错误
|
|
26
|
+
*/
|
|
27
|
+
export declare class FlowCancelSaveException extends Error {
|
|
28
|
+
constructor(message?: string);
|
|
29
|
+
}
|
package/lib/utils/exceptions.js
CHANGED
|
@@ -27,6 +27,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var exceptions_exports = {};
|
|
29
29
|
__export(exceptions_exports, {
|
|
30
|
+
FlowCancelSaveException: () => FlowCancelSaveException,
|
|
30
31
|
FlowExitAllException: () => FlowExitAllException,
|
|
31
32
|
FlowExitException: () => FlowExitException
|
|
32
33
|
});
|
|
@@ -55,8 +56,17 @@ const _FlowExitAllException = class _FlowExitAllException extends Error {
|
|
|
55
56
|
};
|
|
56
57
|
__name(_FlowExitAllException, "FlowExitAllException");
|
|
57
58
|
let FlowExitAllException = _FlowExitAllException;
|
|
59
|
+
const _FlowCancelSaveException = class _FlowCancelSaveException extends Error {
|
|
60
|
+
constructor(message = "Flow settings save cancelled.") {
|
|
61
|
+
super(message);
|
|
62
|
+
this.name = "FlowCancelSaveException";
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
__name(_FlowCancelSaveException, "FlowCancelSaveException");
|
|
66
|
+
let FlowCancelSaveException = _FlowCancelSaveException;
|
|
58
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
68
|
0 && (module.exports = {
|
|
69
|
+
FlowCancelSaveException,
|
|
60
70
|
FlowExitAllException,
|
|
61
71
|
FlowExitException
|
|
62
72
|
});
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { BLOCK_GROUP_CONFIGS, BLOCK_TYPES, FLOW_ENGINE_NAMESPACE, MENU_KEYS, type BlockBuilderConfig, } from './constants';
|
|
10
10
|
export { escapeT, getT, tExpr } from './translation';
|
|
11
|
-
export { FlowExitException } from './exceptions';
|
|
11
|
+
export { FlowCancelSaveException, 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, shouldHideStepInSettings } from './schema-utils';
|
|
15
|
+
export { compileUiSchema, resolveStepUiSchema, resolveStepDisabledInSettings, resolveUiMode, shouldHideStepInSettings, } from './schema-utils';
|
|
16
16
|
export { setupRuntimeContextSteps } from './setupRuntimeContextSteps';
|
|
17
17
|
export { createCollectionContextMeta } from './createCollectionContextMeta';
|
|
18
18
|
export { createAssociationAwareObjectMetaFactory, createAssociationSubpathResolver } from './associationObjectVariable';
|
|
@@ -20,7 +20,12 @@ export { buildRecordMeta, collectContextParamsForTemplate, createCurrentRecordMe
|
|
|
20
20
|
export { extractPropertyPath, formatPathToVariable, isVariableExpression } from './context';
|
|
21
21
|
export { clearAutoFlowError, getAutoFlowError, setAutoFlowError, type AutoFlowError } from './autoFlowError';
|
|
22
22
|
export { parsePathnameToViewParams, type ViewParam } from './parsePathnameToViewParams';
|
|
23
|
-
export {
|
|
23
|
+
export { decodeBase64Url, encodeBase64Url, isCompleteCtxDatePath, isCtxDatePathPrefix, isCtxDateExpression, parseCtxDateExpression, resolveCtxDatePath, serializeCtxDateValue, } from './dateVariable';
|
|
24
|
+
export { createSafeDocument, createSafeWindow, createSafeNavigator, createSafeRunJSGlobals, runjsWithSafeGlobals, } from './safeGlobals';
|
|
25
|
+
export { isRunJSValue, normalizeRunJSValue, extractUsedVariablePathsFromRunJS, type RunJSValue } from './runjsValue';
|
|
26
|
+
export { resolveRunJSObjectValues } from './resolveRunJSObjectValues';
|
|
27
|
+
export { prepareRunJsCode, preprocessRunJsTemplates } from './runjsTemplateCompat';
|
|
24
28
|
export { createEphemeralContext } from './createEphemeralContext';
|
|
25
29
|
export { pruneFilter } from './pruneFilter';
|
|
26
30
|
export { isBeforeRenderFlow } from './flows';
|
|
31
|
+
export { resolveModuleUrl, isCssFile } from './resolveModuleUrl';
|