@nocobase/plugin-flow-engine 2.1.0-beta.36 → 2.1.0-beta.37

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.
@@ -297,6 +297,85 @@ const AST_CTX_METHOD_NAMES = /* @__PURE__ */ new Set(["runjs", "makeResource", "
297
297
  const REACT_NODE_COMPONENT_PROP_NAMES = /* @__PURE__ */ new Set(["avatar", "extra", "icon", "prefix", "suffix"]);
298
298
  const CANONICAL_CTX_LIB_MEMBERS = ["React", "ReactDOM", "antd", "dayjs", "antdIcons", "lodash", "formula", "math"];
299
299
  const CTX_LIB_MEMBER_BY_LOWERCASE = new Map(CANONICAL_CTX_LIB_MEMBERS.map((member) => [member.toLowerCase(), member]));
300
+ const RUNJS_CTX_LIB_ANTD_ALLOWED_MEMBERS = /* @__PURE__ */ new Set([
301
+ "Affix",
302
+ "Alert",
303
+ "Anchor",
304
+ "App",
305
+ "AutoComplete",
306
+ "Avatar",
307
+ "BackTop",
308
+ "Badge",
309
+ "Breadcrumb",
310
+ "Button",
311
+ "Calendar",
312
+ "Card",
313
+ "Carousel",
314
+ "Cascader",
315
+ "Checkbox",
316
+ "Col",
317
+ "Collapse",
318
+ "ColorPicker",
319
+ "ConfigProvider",
320
+ "DatePicker",
321
+ "Descriptions",
322
+ "Divider",
323
+ "Drawer",
324
+ "Dropdown",
325
+ "Empty",
326
+ "Flex",
327
+ "FloatButton",
328
+ "Form",
329
+ "Grid",
330
+ "Image",
331
+ "Input",
332
+ "InputNumber",
333
+ "Layout",
334
+ "List",
335
+ "Mentions",
336
+ "Menu",
337
+ "Modal",
338
+ "Pagination",
339
+ "Popconfirm",
340
+ "Popover",
341
+ "Progress",
342
+ "QRCode",
343
+ "Radio",
344
+ "Rate",
345
+ "Result",
346
+ "Row",
347
+ "Segmented",
348
+ "Select",
349
+ "Skeleton",
350
+ "Slider",
351
+ "Space",
352
+ "Spin",
353
+ "Splitter",
354
+ "Statistic",
355
+ "Steps",
356
+ "Switch",
357
+ "Table",
358
+ "Tabs",
359
+ "Tag",
360
+ "TimePicker",
361
+ "Timeline",
362
+ "Tooltip",
363
+ "Tour",
364
+ "Transfer",
365
+ "Tree",
366
+ "TreeSelect",
367
+ "Typography",
368
+ "Upload",
369
+ "Watermark",
370
+ "message",
371
+ "notification",
372
+ "theme",
373
+ "unstableSetRender",
374
+ "version"
375
+ ]);
376
+ const RUNJS_CTX_LIB_ALLOWED_MEMBERS_BY_LIBRARY = /* @__PURE__ */ new Map([
377
+ ["antd", RUNJS_CTX_LIB_ANTD_ALLOWED_MEMBERS]
378
+ ]);
300
379
  const RUNJS_CTX_API_ALLOWED_MEMBERS = /* @__PURE__ */ new Set(["auth", "request", "resource"]);
301
380
  const RUNJS_CTX_API_AUTH_ALLOWED_MEMBERS = /* @__PURE__ */ new Set(["authenticator", "locale", "role", "token"]);
302
381
  const RUNJS_RESOURCE_METHODS = /* @__PURE__ */ new Set(["list", "get", "create", "update", "destroy"]);
@@ -382,7 +461,6 @@ const MULTI_RECORD_RESOURCE_METHODS = unionMethodSets([
382
461
  "setUpdateActionOptions",
383
462
  "setSelectedRows",
384
463
  "getSelectedRows",
385
- "getCount",
386
464
  "setPage",
387
465
  "getPage",
388
466
  "setPageSize",
@@ -437,7 +515,10 @@ const FLOW_RESOURCE_METHODS_BY_TYPE = {
437
515
  SQLResource: SQL_RESOURCE_METHODS
438
516
  };
439
517
  const UNKNOWN_FLOW_RESOURCE_METHODS = unionMethodSets(Object.values(FLOW_RESOURCE_METHODS_BY_TYPE));
440
- const FLOW_RESOURCE_METHOD_SUGGESTIONS = /* @__PURE__ */ new Map([["setFilters", "setFilter"]]);
518
+ const FLOW_RESOURCE_METHOD_SUGGESTIONS = /* @__PURE__ */ new Map([
519
+ ["setFilters", "setFilter"],
520
+ ["getCount", "getData"]
521
+ ]);
441
522
  const CONTEXT_FIRST_REPAIR_CLASSES = /* @__PURE__ */ new Set([
442
523
  "unknown-surface-stop",
443
524
  "unknown-model-stop",
@@ -1720,6 +1801,28 @@ function collectCtxContractErrors(path, source, scan, modelUse, surface, errors)
1720
1801
  })
1721
1802
  );
1722
1803
  });
1804
+ scan.invalidCtxLibMemberAccesses.forEach((entry) => {
1805
+ const importHint = entry.suggestedImport ? `; import it with await ctx.importAsync('${entry.suggestedImport}') instead` : "";
1806
+ errors.push(
1807
+ buildRunJsAuthoringError({
1808
+ path,
1809
+ repairClass: "ctx-libs-member-mismatch-stop",
1810
+ ruleId: entry.ruleId,
1811
+ message: `flowSurfaces authoring ${path} ${entry.capability} is not a supported RunJS ctx.libs.${entry.library} member${importHint}`,
1812
+ modelUse,
1813
+ surface,
1814
+ index: entry.index,
1815
+ source,
1816
+ details: {
1817
+ accessKind: entry.accessKind,
1818
+ capability: entry.capability,
1819
+ library: entry.library,
1820
+ member: entry.member,
1821
+ suggestedImport: entry.suggestedImport
1822
+ }
1823
+ })
1824
+ );
1825
+ });
1723
1826
  scan.invalidCtxApiMemberAccesses.forEach((entry) => {
1724
1827
  const message = entry.ruleId === "runjs-ctx-api-member-dynamic-unresolved" ? `flowSurfaces authoring ${path} cannot validate dynamic ${entry.capability} access` : entry.ruleId === "runjs-ctx-api-auth-member-readonly" ? `flowSurfaces authoring ${path} cannot write readonly RunJS ${entry.capability}; read ctx.api.auth.locale, role, token, or authenticator without mutating them` : entry.ruleId === "runjs-ctx-api-auth-member-unsupported" ? `flowSurfaces authoring ${path} ${entry.capability} is not a supported RunJS ctx.api.auth member; read ctx.api.auth.locale, role, token, or authenticator instead` : `flowSurfaces authoring ${path} ${entry.capability} is not a supported RunJS ctx.api member; use ctx.request(...), ctx.api.request(...), ctx.api.resource(...), or readonly ctx.api.auth fields`;
1725
1828
  errors.push(
@@ -1867,6 +1970,7 @@ function scanJavaScriptSource(source, ast, context = {}) {
1867
1970
  ctxAliases,
1868
1971
  ctxLibMemberCaseMismatches: collectCtxLibMemberCaseMismatches(source, masked, sourceBindings),
1869
1972
  invalidCtxApiMemberAccesses: (astInspection == null ? void 0 : astInspection.invalidCtxApiMemberAccesses) || [],
1973
+ invalidCtxLibMemberAccesses: (astInspection == null ? void 0 : astInspection.invalidCtxLibMemberAccesses) || [],
1870
1974
  forbiddenBareGlobals,
1871
1975
  ctxMemberAccesses: collectCtxMemberAccesses(masked, sourceBindings),
1872
1976
  dynamicCtxAccesses: findUnboundCtxMatches(masked, /\bctx\s*(?:\?\.\s*)?\[/g, sourceBindings),
@@ -1877,6 +1981,8 @@ function inspectRunJsAst(ast, source, stringBindings, context = {}) {
1877
1981
  const identifierBindings = collectAstIdentifierBindingsFromAst(ast, source);
1878
1982
  const aliases = collectCtxMethodAliasesFromAst(ast, source, identifierBindings);
1879
1983
  const ctxApiAliases = collectCtxApiAliasesFromAst(ast, source, identifierBindings);
1984
+ const ctxLibsRootAliases = collectCtxLibsRootAliasesFromAst(ast, source, identifierBindings);
1985
+ const ctxLibAliases = collectCtxLibAliasesFromAst(ast, source, ctxLibsRootAliases, identifierBindings);
1880
1986
  const ctxApiResourceAliases = collectCtxApiResourceAliasesFromAst(ast, source, ctxApiAliases, identifierBindings);
1881
1987
  const reactNamespaceAliases = collectReactNamespaceAliasesFromAst(ast, source, identifierBindings);
1882
1988
  const reactCreateElementAliases = collectReactCreateElementAliasesFromAst(
@@ -1898,6 +2004,9 @@ function inspectRunJsAst(ast, source, stringBindings, context = {}) {
1898
2004
  const invalidCtxApiMemberAccesses = [
1899
2005
  ...collectAstInvalidCtxApiPatternAccesses(ast, ctxApiAliases, identifierBindings)
1900
2006
  ];
2007
+ const invalidCtxLibMemberAccesses = [
2008
+ ...collectAstInvalidCtxLibPatternAccesses(ast, ctxLibAliases, ctxLibsRootAliases, identifierBindings, source)
2009
+ ];
1901
2010
  const invalidApiResourceCalls = [];
1902
2011
  const invalidResourceTypeCalls = [];
1903
2012
  const invalidFlowResourceListCalls = [];
@@ -1963,6 +2072,16 @@ function inspectRunJsAst(ast, source, stringBindings, context = {}) {
1963
2072
  ).forEach((entry) => reactAsyncComponentReferences.push(entry));
1964
2073
  },
1965
2074
  MemberExpression(node) {
2075
+ const invalidCtxLibAccess = collectAstInvalidCtxLibMemberAccess(
2076
+ node,
2077
+ ctxLibAliases,
2078
+ ctxLibsRootAliases,
2079
+ identifierBindings,
2080
+ source
2081
+ );
2082
+ if (invalidCtxLibAccess) {
2083
+ invalidCtxLibMemberAccesses.push(invalidCtxLibAccess);
2084
+ }
1966
2085
  const invalidCtxApiAccess = collectAstInvalidCtxApiMemberAccess(node, ctxApiAliases, identifierBindings, source);
1967
2086
  if (invalidCtxApiAccess) {
1968
2087
  invalidCtxApiMemberAccesses.push(invalidCtxApiAccess);
@@ -2006,6 +2125,9 @@ function inspectRunJsAst(ast, source, stringBindings, context = {}) {
2006
2125
  dedupeIndexedEntries(invalidCtxApiMemberAccesses),
2007
2126
  dedupedInvalidApiResourceCalls
2008
2127
  ).sort((left, right) => left.index - right.index),
2128
+ invalidCtxLibMemberAccesses: dedupeIndexedEntries(invalidCtxLibMemberAccesses).sort(
2129
+ (left, right) => left.index - right.index
2130
+ ),
2009
2131
  invalidResourceTypeCalls: dedupeAstResourceEntries(invalidResourceTypeCalls),
2010
2132
  invalidFlowResourceListCalls: dedupeIndexedEntries(invalidFlowResourceListCalls).sort(
2011
2133
  (left, right) => left.index - right.index
@@ -2150,6 +2272,117 @@ function collectCtxApiObjectPatternAliases(pattern, capability, addAlias) {
2150
2272
  function trimCtxApiAliasesAfterWrites(aliases, writes, identifierBindings) {
2151
2273
  return trimAstAliasesAfterWrites(aliases, writes, identifierBindings);
2152
2274
  }
2275
+ function collectCtxLibsRootAliasesFromAst(ast, source, identifierBindings) {
2276
+ const aliases = [];
2277
+ const writes = collectAstIdentifierWritesFromAst(ast, source);
2278
+ const addAlias = (name, node, ancestors, isVar = false) => {
2279
+ const scope = getAstBindingScopeRange(ancestors, source.length, isVar);
2280
+ aliases.push({
2281
+ capability: "ctx.libs",
2282
+ declarationStart: typeof (node == null ? void 0 : node.start) === "number" ? node.start : scope.start,
2283
+ executionScope: getAstExecutionScopeRange(ancestors, source.length),
2284
+ name,
2285
+ start: typeof (node == null ? void 0 : node.start) === "number" ? node.start : scope.start,
2286
+ end: scope.end
2287
+ });
2288
+ };
2289
+ const getActiveAliases = () => trimAstAliasesAfterWrites(aliases, writes, identifierBindings);
2290
+ walkAstAncestor(ast, {
2291
+ AssignmentExpression(node, ancestors) {
2292
+ var _a;
2293
+ if (!isAstCtxApiAliasAssignmentOperator(node.operator)) {
2294
+ return;
2295
+ }
2296
+ if (((_a = node.left) == null ? void 0 : _a.type) === "Identifier" && isCtxLibsRootFromAst(node.right, getActiveAliases(), identifierBindings)) {
2297
+ addAlias(node.left.name, node, ancestors);
2298
+ }
2299
+ },
2300
+ VariableDeclarator(node, ancestors) {
2301
+ var _a;
2302
+ if (((_a = node.id) == null ? void 0 : _a.type) !== "Identifier" || !isCtxLibsRootFromAst(node.init, getActiveAliases(), identifierBindings)) {
2303
+ return;
2304
+ }
2305
+ const declaration = findAstAncestor(ancestors, "VariableDeclaration");
2306
+ addAlias(node.id.name, node, ancestors, (declaration == null ? void 0 : declaration.kind) === "var");
2307
+ }
2308
+ });
2309
+ return trimAstAliasesAfterWrites(aliases, writes, identifierBindings);
2310
+ }
2311
+ function collectCtxLibAliasesFromAst(ast, source, rootAliases, identifierBindings) {
2312
+ const aliases = [];
2313
+ const writes = collectAstIdentifierWritesFromAst(ast, source);
2314
+ const addAlias = (name, library, capability, node, ancestors, isVar = false) => {
2315
+ const scope = getAstBindingScopeRange(ancestors, source.length, isVar);
2316
+ aliases.push({
2317
+ capability,
2318
+ declarationStart: typeof (node == null ? void 0 : node.start) === "number" ? node.start : scope.start,
2319
+ executionScope: getAstExecutionScopeRange(ancestors, source.length),
2320
+ library,
2321
+ name,
2322
+ start: typeof (node == null ? void 0 : node.start) === "number" ? node.start : scope.start,
2323
+ end: scope.end
2324
+ });
2325
+ };
2326
+ const getActiveAliases = () => trimAstAliasesAfterWrites(aliases, writes, identifierBindings);
2327
+ walkAstAncestor(ast, {
2328
+ AssignmentExpression(node, ancestors) {
2329
+ var _a, _b;
2330
+ if (!isAstCtxApiAliasAssignmentOperator(node.operator)) {
2331
+ return;
2332
+ }
2333
+ const activeAliases = getActiveAliases();
2334
+ const sourcePath = getCtxLibMemberPathFromAst(node.right, activeAliases, rootAliases, identifierBindings, source);
2335
+ if (((_a = node.left) == null ? void 0 : _a.type) === "Identifier" && sourcePath && !sourcePath.hasDynamicMember && !sourcePath.members.length) {
2336
+ addAlias(node.left.name, sourcePath.library, sourcePath.rootCapability, node, ancestors);
2337
+ return;
2338
+ }
2339
+ if (node.operator === "=" && ((_b = node.left) == null ? void 0 : _b.type) === "ObjectPattern") {
2340
+ collectCtxLibObjectPatternAliases(
2341
+ node.left,
2342
+ node.right,
2343
+ rootAliases,
2344
+ identifierBindings,
2345
+ (name, alias, aliasNode) => {
2346
+ addAlias(name, alias.library, alias.capability, aliasNode || node, ancestors);
2347
+ }
2348
+ );
2349
+ }
2350
+ },
2351
+ VariableDeclarator(node, ancestors) {
2352
+ var _a, _b;
2353
+ const declaration = findAstAncestor(ancestors, "VariableDeclaration");
2354
+ const isVar = (declaration == null ? void 0 : declaration.kind) === "var";
2355
+ const activeAliases = getActiveAliases();
2356
+ const sourcePath = getCtxLibMemberPathFromAst(node.init, activeAliases, rootAliases, identifierBindings, source);
2357
+ if (((_a = node.id) == null ? void 0 : _a.type) === "Identifier" && sourcePath && !sourcePath.hasDynamicMember && !sourcePath.members.length) {
2358
+ addAlias(node.id.name, sourcePath.library, sourcePath.rootCapability, node, ancestors, isVar);
2359
+ return;
2360
+ }
2361
+ if (((_b = node.id) == null ? void 0 : _b.type) === "ObjectPattern") {
2362
+ collectCtxLibObjectPatternAliases(
2363
+ node.id,
2364
+ node.init,
2365
+ rootAliases,
2366
+ identifierBindings,
2367
+ (name, alias, aliasNode) => {
2368
+ addAlias(name, alias.library, alias.capability, aliasNode || node, ancestors, isVar);
2369
+ }
2370
+ );
2371
+ }
2372
+ }
2373
+ });
2374
+ return trimAstAliasesAfterWrites(aliases, writes, identifierBindings);
2375
+ }
2376
+ function collectCtxLibObjectPatternAliases(pattern, sourceNode, rootAliases, identifierBindings, addAlias) {
2377
+ if (!isCtxLibsRootFromAst(sourceNode, rootAliases, identifierBindings)) {
2378
+ return;
2379
+ }
2380
+ collectAstObjectPatternAliases(pattern, (name, member, aliasNode) => {
2381
+ if (member) {
2382
+ addAlias(name, { capability: `ctx.libs.${member}`, library: member }, aliasNode);
2383
+ }
2384
+ });
2385
+ }
2153
2386
  function trimAstAliasesAfterWrites(aliases, writes, identifierBindings) {
2154
2387
  return aliases.map((alias) => {
2155
2388
  const aliasDeclarationStart = alias.declarationStart ?? alias.start;
@@ -4199,6 +4432,183 @@ function getSuggestedFlowResourceMethod(method) {
4199
4432
  function isKnownFlowResourceInstanceType(value) {
4200
4433
  return value in FLOW_RESOURCE_METHODS_BY_TYPE;
4201
4434
  }
4435
+ function collectAstInvalidCtxLibPatternAccesses(ast, aliases, rootAliases, identifierBindings, source) {
4436
+ const entries = [];
4437
+ const collectPattern = (pattern, sourceNode) => {
4438
+ const sourcePath = getCtxLibMemberPathFromAst(sourceNode, aliases, rootAliases, identifierBindings, source);
4439
+ if (!sourcePath || sourcePath.hasDynamicMember || sourcePath.members.length) {
4440
+ return;
4441
+ }
4442
+ collectInvalidCtxLibObjectPatternAccesses(pattern, sourcePath).forEach((entry) => entries.push(entry));
4443
+ };
4444
+ walkAstAncestor(ast, {
4445
+ AssignmentExpression(node) {
4446
+ var _a;
4447
+ if (node.operator !== "=" || ((_a = node.left) == null ? void 0 : _a.type) !== "ObjectPattern") {
4448
+ return;
4449
+ }
4450
+ collectPattern(node.left, node.right);
4451
+ },
4452
+ VariableDeclarator(node) {
4453
+ var _a;
4454
+ if (((_a = node.id) == null ? void 0 : _a.type) !== "ObjectPattern") {
4455
+ return;
4456
+ }
4457
+ collectPattern(node.id, node.init);
4458
+ }
4459
+ });
4460
+ return dedupeIndexedEntries(entries);
4461
+ }
4462
+ function collectInvalidCtxLibObjectPatternAccesses(pattern, sourcePath) {
4463
+ var _a;
4464
+ const entries = [];
4465
+ for (const property of (pattern == null ? void 0 : pattern.properties) || []) {
4466
+ if (!property || property.type !== "Property") {
4467
+ continue;
4468
+ }
4469
+ const member = getAstStaticPropertyName(property);
4470
+ if (!member) {
4471
+ continue;
4472
+ }
4473
+ const invalidAccess = buildInvalidCtxLibMemberAccess({
4474
+ ...sourcePath,
4475
+ members: [
4476
+ {
4477
+ accessKind: "destructure",
4478
+ index: typeof ((_a = property.key) == null ? void 0 : _a.start) === "number" ? property.key.start : property.start || 0,
4479
+ name: member
4480
+ }
4481
+ ]
4482
+ });
4483
+ if (invalidAccess) {
4484
+ entries.push(invalidAccess);
4485
+ }
4486
+ }
4487
+ return entries;
4488
+ }
4489
+ function collectAstInvalidCtxLibMemberAccess(node, aliases, rootAliases, identifierBindings, source) {
4490
+ const path = getCtxLibMemberPathFromAst(node, aliases, rootAliases, identifierBindings, source);
4491
+ if (!path || path.hasDynamicMember || !path.members.length) {
4492
+ return void 0;
4493
+ }
4494
+ return buildInvalidCtxLibMemberAccess(path);
4495
+ }
4496
+ function buildInvalidCtxLibMemberAccess(path) {
4497
+ const allowedMembers = RUNJS_CTX_LIB_ALLOWED_MEMBERS_BY_LIBRARY.get(path.library);
4498
+ const member = path.members[0];
4499
+ if (!allowedMembers || !member || allowedMembers.has(member.name)) {
4500
+ return void 0;
4501
+ }
4502
+ return {
4503
+ accessKind: member.accessKind,
4504
+ capability: getCtxLibMemberCapability(path.rootCapability, member),
4505
+ index: member.index,
4506
+ library: path.library,
4507
+ member: member.name,
4508
+ ruleId: "runjs-ctx-libs-member-unknown",
4509
+ suggestedImport: getSuggestedCtxLibMemberImport(path.library, member.name)
4510
+ };
4511
+ }
4512
+ function getCtxLibMemberCapability(rootCapability, member) {
4513
+ return member.accessKind === "bracket" ? `${rootCapability}[${JSON.stringify(member.name)}]` : `${rootCapability}.${member.name}`;
4514
+ }
4515
+ function getSuggestedCtxLibMemberImport(library, member) {
4516
+ if (library === "antd" && member === "colors") {
4517
+ return "@ant-design/colors";
4518
+ }
4519
+ return void 0;
4520
+ }
4521
+ function getCtxLibMemberPathFromAst(node, aliases, rootAliases, identifierBindings, source) {
4522
+ var _a;
4523
+ const unwrapped = unwrapAstChainExpression(node);
4524
+ if (!unwrapped) {
4525
+ return void 0;
4526
+ }
4527
+ if (unwrapped.type === "Identifier") {
4528
+ const alias = resolveAstAliasBinding(unwrapped.name, unwrapped.start || 0, aliases, identifierBindings);
4529
+ if (!alias) {
4530
+ return void 0;
4531
+ }
4532
+ const index = typeof unwrapped.start === "number" ? unwrapped.start : alias.start;
4533
+ return {
4534
+ dynamicIndex: index,
4535
+ hasDynamicMember: false,
4536
+ library: alias.library,
4537
+ libraryIndex: index,
4538
+ memberIndex: index,
4539
+ members: [],
4540
+ rootCapability: alias.capability
4541
+ };
4542
+ }
4543
+ if (unwrapped.type !== "MemberExpression") {
4544
+ return void 0;
4545
+ }
4546
+ const objectPath = getCtxLibMemberPathFromAst(unwrapped.object, aliases, rootAliases, identifierBindings, source);
4547
+ if (objectPath) {
4548
+ const propertyName = getAstStaticPropertyName(unwrapped);
4549
+ const propertyIndex = typeof ((_a = unwrapped.property) == null ? void 0 : _a.start) === "number" ? unwrapped.property.start : unwrapped.start || 0;
4550
+ return {
4551
+ ...objectPath,
4552
+ dynamicIndex: propertyName ? objectPath.dynamicIndex : propertyIndex,
4553
+ hasDynamicMember: objectPath.hasDynamicMember || !propertyName,
4554
+ memberIndex: objectPath.members.length ? objectPath.memberIndex : propertyIndex,
4555
+ members: propertyName ? [
4556
+ ...objectPath.members,
4557
+ {
4558
+ accessKind: unwrapped.computed ? "bracket" : "member",
4559
+ index: propertyIndex,
4560
+ name: propertyName
4561
+ }
4562
+ ] : objectPath.members
4563
+ };
4564
+ }
4565
+ return getDirectCtxLibPathFromAst(unwrapped, rootAliases, identifierBindings, source);
4566
+ }
4567
+ function getDirectCtxLibPathFromAst(node, rootAliases, identifierBindings, source) {
4568
+ var _a;
4569
+ const member = unwrapAstChainExpression(node);
4570
+ if (!member || member.type !== "MemberExpression") {
4571
+ return void 0;
4572
+ }
4573
+ const propertyName = getAstStaticPropertyName(member);
4574
+ if (!propertyName) {
4575
+ return void 0;
4576
+ }
4577
+ const propertyIndex = typeof ((_a = member.property) == null ? void 0 : _a.start) === "number" ? member.property.start : member.start || 0;
4578
+ if (isCtxLibsRootFromAst(member.object, rootAliases, identifierBindings)) {
4579
+ return {
4580
+ dynamicIndex: propertyIndex,
4581
+ hasDynamicMember: false,
4582
+ library: propertyName,
4583
+ libraryIndex: propertyIndex,
4584
+ memberIndex: propertyIndex,
4585
+ members: [],
4586
+ rootCapability: getAstSource(member, source) || `ctx.libs.${propertyName}`
4587
+ };
4588
+ }
4589
+ if (CANONICAL_CTX_LIB_MEMBERS.includes(propertyName) && isUnshadowedCtxIdentifier(member.object, identifierBindings)) {
4590
+ return {
4591
+ dynamicIndex: propertyIndex,
4592
+ hasDynamicMember: false,
4593
+ library: propertyName,
4594
+ libraryIndex: propertyIndex,
4595
+ memberIndex: propertyIndex,
4596
+ members: [],
4597
+ rootCapability: getAstSource(member, source) || `ctx.${propertyName}`
4598
+ };
4599
+ }
4600
+ return void 0;
4601
+ }
4602
+ function isCtxLibsRootFromAst(node, rootAliases, identifierBindings) {
4603
+ const unwrapped = unwrapAstChainExpression(node);
4604
+ if (!unwrapped) {
4605
+ return false;
4606
+ }
4607
+ if (unwrapped.type === "Identifier") {
4608
+ return !!resolveAstAliasBinding(unwrapped.name, unwrapped.start || 0, rootAliases, identifierBindings);
4609
+ }
4610
+ return unwrapped.type === "MemberExpression" && getAstStaticPropertyName(unwrapped) === "libs" && isUnshadowedCtxIdentifier(unwrapped.object, identifierBindings);
4611
+ }
4202
4612
  function collectAstInvalidCtxApiPatternAccesses(ast, aliases, identifierBindings) {
4203
4613
  const entries = [];
4204
4614
  const collectPattern = (pattern, capability) => {
@@ -9,13 +9,19 @@
9
9
  import type { Plugin } from '@nocobase/server';
10
10
  import _ from 'lodash';
11
11
  import FlowModelRepository from '../repository';
12
+ import type { FlowSurfaceApplyBlueprintDocument } from './blueprint';
12
13
  import { SurfaceLocator } from './locator';
13
14
  import type { TemplateTranslate } from './template-display';
14
15
  import type { FlowSurfaceActionLinkageRule, FlowSurfaceBlockLinkageRule, FlowSurfaceFieldLinkageRule, FlowSurfaceFieldValueRule, FlowSurfaceGetReactionMetaResult, FlowSurfaceGetReactionMetaValues, FlowSurfaceReactionWriteResult, FlowSurfaceReactionWriteValues } from './reaction/types';
15
16
  import type { FlowSurfaceTemplateListPopupActionContext, FlowSurfaceTemplateListValues, FlowSurfaceTemplateRow } from './template-service-utils';
16
- import type { FlowSurfaceApplyValues, FlowSurfaceCatalogResponse, FlowSurfaceCatalogValues, FlowSurfaceComposeValues, FlowSurfaceConfigureValues, FlowSurfaceContextValues, FlowSurfaceDescribeValues, FlowSurfaceMutateValues } from './types';
17
+ import type { FlowSurfaceApplyValues, FlowSurfaceActionScope, FlowSurfaceCatalogResponse, FlowSurfaceCatalogValues, FlowSurfaceComposeValues, FlowSurfaceConfigureValues, FlowSurfaceContextValues, FlowSurfaceDescribeValues, FlowSurfaceMutateValues } from './types';
18
+ import type { FlowSurfaceContextResponse, FlowSurfaceContextVarInfo } from './types';
17
19
  type FlowSurfacePopupTemplateAliasSession = Map<string, string>;
18
20
  type FlowSurfaceRequestRoles = readonly string[] | string;
21
+ type FlowSurfaceReadOptions = {
22
+ transaction?: any;
23
+ currentRoles?: FlowSurfaceRequestRoles;
24
+ };
19
25
  type FlowSurfaceAddFieldResult = {
20
26
  uid?: string;
21
27
  parentUid?: string;
@@ -34,6 +40,12 @@ type FlowSurfaceAddFieldResult = {
34
40
  popupGridUid?: string;
35
41
  };
36
42
  type FlowSurfacePopupTemplateTreeCache = Map<string, Promise<any | null> | any | null>;
43
+ type FlowSurfaceApplyBlueprintResponse = {
44
+ version: '1';
45
+ mode: FlowSurfaceApplyBlueprintDocument['mode'];
46
+ target: Record<string, any>;
47
+ surface: any;
48
+ };
37
49
  export declare class FlowSurfacesService {
38
50
  private readonly plugin;
39
51
  constructor(plugin: Plugin);
@@ -129,7 +141,7 @@ export declare class FlowSurfacesService {
129
141
  private buildAssociatedRecordsResourceInit;
130
142
  context(values: FlowSurfaceContextValues, options?: {
131
143
  transaction?: any;
132
- }): Promise<import("./types").FlowSurfaceContextResponse>;
144
+ }): Promise<FlowSurfaceContextResponse>;
133
145
  private extractReactionCanonicalRules;
134
146
  private buildReactionFieldPathMaps;
135
147
  private extractReactionFieldPaths;
@@ -162,9 +174,7 @@ export declare class FlowSurfacesService {
162
174
  private stripInternalSurfaceMetaFromNodeTree;
163
175
  private buildSurfaceReadPayload;
164
176
  private buildSurfaceContextFingerprint;
165
- get(input: Record<string, any>, options?: {
166
- transaction?: any;
167
- }): Promise<Record<string, any>>;
177
+ get(input: Record<string, any>, options?: FlowSurfaceReadOptions): Promise<Record<string, any>>;
168
178
  private getDeclaredKeyPersistenceDeps;
169
179
  private patchDeclaredKeyModel;
170
180
  private persistCreatedKeysForAction;
@@ -177,6 +187,7 @@ export declare class FlowSurfacesService {
177
187
  private resolveApplyBlueprintCreateNavigationGroup;
178
188
  private resolveApplyBlueprintCreatePageIdentity;
179
189
  private prepareApplyBlueprintRequest;
190
+ private prevalidateApplyBlueprintChartAssets;
180
191
  private getApplyBlueprintKanbanBlockResourceObject;
181
192
  private normalizeApplyBlueprintKanbanResourceText;
182
193
  private getApplyBlueprintKanbanBlockBinding;
@@ -201,13 +212,11 @@ export declare class FlowSurfacesService {
201
212
  applyBlueprint(values: Record<string, any>, options?: {
202
213
  transaction?: any;
203
214
  currentRoles?: FlowSurfaceRequestRoles;
204
- }): Promise<{
205
- version: string;
206
- mode: import("./blueprint").FlowSurfaceApplyBlueprintMode;
207
- target: _.Dictionary<any>;
208
- surface: Record<string, any>;
209
- }>;
215
+ }): Promise<FlowSurfaceApplyBlueprintResponse>;
216
+ private applyBlueprintMutationWithoutExternalTransaction;
217
+ private assertApplyBlueprintAuthoringPayload;
210
218
  private applyBlueprintWithTransaction;
219
+ private buildApplyBlueprintResponse;
211
220
  private findApprovalSurfaceRootForNode;
212
221
  private syncApprovalRuntimeConfigForSurfaceRoot;
213
222
  private syncApprovalRuntimeConfigForNode;
@@ -456,7 +465,7 @@ export declare class FlowSurfacesService {
456
465
  uid: any;
457
466
  parentUid: any;
458
467
  subKey: string;
459
- scope: import("./types").FlowSurfaceActionScope;
468
+ scope: FlowSurfaceActionScope;
460
469
  }>;
461
470
  addRecordAction(values: Record<string, any>, options?: {
462
471
  transaction?: any;
@@ -469,7 +478,7 @@ export declare class FlowSurfacesService {
469
478
  uid: any;
470
479
  parentUid: any;
471
480
  subKey: string;
472
- scope: import("./types").FlowSurfaceActionScope;
481
+ scope: FlowSurfaceActionScope;
473
482
  }>;
474
483
  addBlocks(values: Record<string, any>): Promise<{
475
484
  [x: string]: number | Record<string, any>[];
@@ -727,6 +736,7 @@ export declare class FlowSurfacesService {
727
736
  private normalizeChartSelectionFieldPath;
728
737
  private validateBuilderChartFieldsForRuntime;
729
738
  private resolveBuilderChartAssociationSubfieldSuggestion;
739
+ private validateChartConfigureForRuntime;
730
740
  private stripChartSqlForInspection;
731
741
  private normalizeReadOnlyChartSql;
732
742
  private buildChartSqlPreviewQuery;
@@ -773,7 +783,7 @@ export declare class FlowSurfacesService {
773
783
  additionalProperties: boolean;
774
784
  };
775
785
  }[];
776
- vars: Record<string, import("./types").FlowSurfaceContextVarInfo>;
786
+ vars: Record<string, FlowSurfaceContextVarInfo>;
777
787
  fingerprint: string;
778
788
  writeCapabilities: {
779
789
  defaultAddPhase: string;
@@ -1006,6 +1016,10 @@ export declare class FlowSurfacesService {
1006
1016
  private assertOnlyAIEmployeePublicSettings;
1007
1017
  private assertOnlyAIEmployeeNestedPublicSettings;
1008
1018
  private assertNoAIEmployeeInternalPropSettings;
1019
+ private readAIEmployeePersistedTasks;
1020
+ private buildAIEmployeeTaskStepParams;
1021
+ private mergeAIEmployeeActionSettingsPayload;
1022
+ private syncAIEmployeeTaskStepParamsForUpdateSettings;
1009
1023
  private assertAIEmployeePluginEnabled;
1010
1024
  private readRecordPlainObject;
1011
1025
  private readRecordField;
@@ -1017,6 +1031,23 @@ export declare class FlowSurfacesService {
1017
1031
  private normalizeAIEmployeeWorkContext;
1018
1032
  private normalizeAIEmployeeTaskModel;
1019
1033
  private normalizeAIEmployeeSkillSettings;
1034
+ private collectAIEmployeePromptVariables;
1035
+ private hasAIEmployeePromptVariables;
1036
+ private collectAIEmployeeContextPathEntries;
1037
+ private isAIEmployeeContextInfoPathAllowed;
1038
+ private canResolveAIEmployeeContextPath;
1039
+ private isAIEmployeeContextPathAllowed;
1040
+ private extractAIEmployeePromptContextPath;
1041
+ private buildAIEmployeePromptVariableHint;
1042
+ private throwAIEmployeePromptVariableInvalid;
1043
+ private assertAIEmployeePromptVariablesAllowed;
1044
+ private assertAIEmployeeTaskPromptVariablesAllowed;
1045
+ private appendAIEmployeeCurrentRecordPromptVariable;
1046
+ private resolveAIEmployeePromptActionTargetUid;
1047
+ private buildAIEmployeePromptValidationContext;
1048
+ private appendAIEmployeeCurrentRecordPromptVariableToTasks;
1049
+ private assertAIEmployeeStepParamTaskPromptVariablesAllowedForUpdateSettings;
1050
+ private normalizeAIEmployeeStepParamTasksForUpdateSettings;
1020
1051
  private normalizeAIEmployeeTaskMessage;
1021
1052
  private normalizeAIEmployeeTaskPatch;
1022
1053
  private normalizeAIEmployeeTasks;