@nocobase/flow-engine 2.1.0-beta.29 → 2.1.0-beta.32

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.
@@ -349,6 +349,7 @@ declare class BaseFlowEngineContext extends FlowContext {
349
349
  runAction: (actionName: string, params?: Record<string, any>) => Promise<any> | any;
350
350
  engine: FlowEngine;
351
351
  api: APIClient;
352
+ locale: string;
352
353
  viewer: FlowViewer;
353
354
  view: FlowView;
354
355
  modal: HookAPI;
@@ -2307,6 +2307,18 @@ const _FlowEngineContext = class _FlowEngineContext extends BaseFlowEngineContex
2307
2307
  this.defineMethod("t", (keyOrTemplate, options) => {
2308
2308
  return i18n.translate(keyOrTemplate, options);
2309
2309
  });
2310
+ this.defineProperty("locale", {
2311
+ get: /* @__PURE__ */ __name(() => {
2312
+ var _a, _b, _c;
2313
+ return ((_b = (_a = this.api) == null ? void 0 : _a.auth) == null ? void 0 : _b.locale) || ((_c = this.i18n) == null ? void 0 : _c.language);
2314
+ }, "get"),
2315
+ cache: false,
2316
+ meta: Object.assign(() => ({ type: "string", title: this.t("Current language"), sort: 970 }), {
2317
+ title: (0, import_utils.escapeT)("Current language"),
2318
+ sort: 970,
2319
+ hasChildren: false
2320
+ })
2321
+ });
2310
2322
  this.defineMethod("renderJson", function(template) {
2311
2323
  return this.resolveJsonTemplate(template);
2312
2324
  });
package/lib/types.d.ts CHANGED
@@ -120,7 +120,9 @@ export declare enum ActionScene {
120
120
  /** 按钮级联动规则可用 */
121
121
  ACTION_LINKAGE_RULES = 5,
122
122
  /** 动态事件流可用 */
123
- DYNAMIC_EVENT_FLOW = 6
123
+ DYNAMIC_EVENT_FLOW = 6,
124
+ /** 菜单项联动规则可用 */
125
+ MENU_LINKAGE_RULES = 7
124
126
  }
125
127
  /**
126
128
  * Defines a reusable action with generic model type support.
package/lib/types.js CHANGED
@@ -36,6 +36,7 @@ var ActionScene = /* @__PURE__ */ ((ActionScene2) => {
36
36
  ActionScene2[ActionScene2["DETAILS_FIELD_LINKAGE_RULES"] = 4] = "DETAILS_FIELD_LINKAGE_RULES";
37
37
  ActionScene2[ActionScene2["ACTION_LINKAGE_RULES"] = 5] = "ACTION_LINKAGE_RULES";
38
38
  ActionScene2[ActionScene2["DYNAMIC_EVENT_FLOW"] = 6] = "DYNAMIC_EVENT_FLOW";
39
+ ActionScene2[ActionScene2["MENU_LINKAGE_RULES"] = 7] = "MENU_LINKAGE_RULES";
39
40
  return ActionScene2;
40
41
  })(ActionScene || {});
41
42
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/flow-engine",
3
- "version": "2.1.0-beta.29",
3
+ "version": "2.1.0-beta.32",
4
4
  "private": false,
5
5
  "description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
6
6
  "main": "lib/index.js",
@@ -8,8 +8,8 @@
8
8
  "dependencies": {
9
9
  "@formily/antd-v5": "1.x",
10
10
  "@formily/reactive": "2.x",
11
- "@nocobase/sdk": "2.1.0-beta.29",
12
- "@nocobase/shared": "2.1.0-beta.29",
11
+ "@nocobase/sdk": "2.1.0-beta.32",
12
+ "@nocobase/shared": "2.1.0-beta.32",
13
13
  "ahooks": "^3.7.2",
14
14
  "axios": "^1.7.0",
15
15
  "dayjs": "^1.11.9",
@@ -37,5 +37,5 @@
37
37
  ],
38
38
  "author": "NocoBase Team",
39
39
  "license": "Apache-2.0",
40
- "gitHead": "86c41be29dcbcac6fd6aa46b4a137ef07a27c1d0"
40
+ "gitHead": "659c5efe992da7118d33c768bbd9e837a2c4716f"
41
41
  }
@@ -160,6 +160,23 @@ describe('FlowContext properties and methods', () => {
160
160
  expect(ctx.shared).toBe('from delegate');
161
161
  });
162
162
 
163
+ it('should expose current language as a top-level variable', async () => {
164
+ const engine = new FlowEngine();
165
+ const ctx = engine.context;
166
+ ctx.defineProperty('api', { value: { auth: { locale: 'zh-CN' } } });
167
+ ctx.defineProperty('i18n', { value: { language: 'en-US' } });
168
+
169
+ expect(ctx.locale).toBe('zh-CN');
170
+ await expect(ctx.resolveJsonTemplate('{{ ctx.locale }}')).resolves.toBe('zh-CN');
171
+
172
+ const localeNode = ctx.getPropertyMetaTree().find((node) => node.name === 'locale');
173
+ expect(localeNode).toMatchObject({
174
+ name: 'locale',
175
+ title: '{{t("Current language")}}',
176
+ paths: ['locale'],
177
+ });
178
+ });
179
+
163
180
  it('should throw sync error in get', () => {
164
181
  const ctx = new FlowContext();
165
182
  ctx.defineProperty('error', {
@@ -1202,6 +1202,7 @@ describe('AddSubModelButton toggleable behavior', () => {
1202
1202
  },
1203
1203
  { timeout: 3000 },
1204
1204
  );
1205
+ await waitFor(() => expect(screen.getByRole('switch')).toHaveAttribute('aria-checked', 'true'));
1205
1206
 
1206
1207
  // dropdown should remain open and children should still be visible (no flicker / reload)
1207
1208
  expect(screen.getByText('Async Group')).toBeInTheDocument();
@@ -1218,6 +1219,7 @@ describe('AddSubModelButton toggleable behavior', () => {
1218
1219
 
1219
1220
  // ensure destroy has been called (avoid flakiness on exact call counts)
1220
1221
  await waitFor(() => {
1222
+ expect(screen.getByRole('switch')).toHaveAttribute('aria-checked', 'false');
1221
1223
  expect(repo.destroy).toHaveBeenCalled();
1222
1224
  });
1223
1225
  });
@@ -3036,6 +3036,7 @@ class BaseFlowEngineContext extends FlowContext {
3036
3036
  declare runAction: (actionName: string, params?: Record<string, any>) => Promise<any> | any;
3037
3037
  declare engine: FlowEngine;
3038
3038
  declare api: APIClient;
3039
+ declare locale: string;
3039
3040
  declare viewer: FlowViewer;
3040
3041
  declare view: FlowView;
3041
3042
  declare modal: HookAPI;
@@ -3146,6 +3147,15 @@ export class FlowEngineContext extends BaseFlowEngineContext {
3146
3147
  this.defineMethod('t', (keyOrTemplate: string, options?: any) => {
3147
3148
  return i18n.translate(keyOrTemplate, options);
3148
3149
  });
3150
+ this.defineProperty('locale', {
3151
+ get: () => this.api?.auth?.locale || this.i18n?.language,
3152
+ cache: false,
3153
+ meta: Object.assign(() => ({ type: 'string', title: this.t('Current language'), sort: 970 }), {
3154
+ title: escapeT('Current language'),
3155
+ sort: 970,
3156
+ hasChildren: false,
3157
+ }),
3158
+ });
3149
3159
  this.defineMethod('renderJson', function (template: any) {
3150
3160
  return this.resolveJsonTemplate(template);
3151
3161
  });
package/src/types.ts CHANGED
@@ -145,6 +145,8 @@ export enum ActionScene {
145
145
  ACTION_LINKAGE_RULES,
146
146
  /** 动态事件流可用 */
147
147
  DYNAMIC_EVENT_FLOW,
148
+ /** 菜单项联动规则可用 */
149
+ MENU_LINKAGE_RULES,
148
150
  }
149
151
 
150
152
  /**