@nocobase/plugin-flow-engine 2.1.0-alpha.19 → 2.1.0-alpha.20

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.
@@ -0,0 +1,178 @@
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 __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var default_block_actions_exports = {};
38
+ __export(default_block_actions_exports, {
39
+ FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY: () => FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY,
40
+ getFlowSurfaceDefaultBlockActions: () => getFlowSurfaceDefaultBlockActions,
41
+ mergeFlowSurfaceDefaultBlockActions: () => mergeFlowSurfaceDefaultBlockActions
42
+ });
43
+ module.exports = __toCommonJS(default_block_actions_exports);
44
+ var import_lodash = __toESM(require("lodash"));
45
+ const FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY = "__flowSurfaceAutoSaveDefaultPopupTemplate";
46
+ const FLOW_SURFACE_DEFAULT_BLOCK_ACTIONS = {
47
+ table: [
48
+ { type: "filter", scope: "actions" },
49
+ {
50
+ type: "addNew",
51
+ scope: "actions",
52
+ popup: {
53
+ tryTemplate: true,
54
+ [FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY]: true
55
+ }
56
+ },
57
+ { type: "refresh", scope: "actions" }
58
+ ],
59
+ list: [
60
+ { type: "filter", scope: "actions" },
61
+ {
62
+ type: "addNew",
63
+ scope: "actions",
64
+ popup: {
65
+ tryTemplate: true,
66
+ [FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY]: true
67
+ }
68
+ },
69
+ { type: "refresh", scope: "actions" }
70
+ ],
71
+ gridCard: [
72
+ { type: "filter", scope: "actions" },
73
+ {
74
+ type: "addNew",
75
+ scope: "actions",
76
+ popup: {
77
+ tryTemplate: true,
78
+ [FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY]: true
79
+ }
80
+ },
81
+ { type: "refresh", scope: "actions" }
82
+ ],
83
+ details: [
84
+ {
85
+ type: "edit",
86
+ scope: "recordActions",
87
+ popup: {
88
+ tryTemplate: true,
89
+ defaultType: "edit",
90
+ [FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY]: true
91
+ }
92
+ }
93
+ ]
94
+ };
95
+ function cloneDefaultActionDescriptor(descriptor) {
96
+ return {
97
+ ...descriptor,
98
+ ...descriptor.popup ? { popup: import_lodash.default.cloneDeep(descriptor.popup) } : {}
99
+ };
100
+ }
101
+ function normalizeActionType(value) {
102
+ return typeof value === "string" ? value.trim() : String(value || "").trim();
103
+ }
104
+ function resolveDefaultBlockActions(blockType, template) {
105
+ const normalizedBlockType = normalizeActionType(blockType);
106
+ if (!normalizedBlockType || !import_lodash.default.isUndefined(template)) {
107
+ return [];
108
+ }
109
+ return (FLOW_SURFACE_DEFAULT_BLOCK_ACTIONS[normalizedBlockType] || []).map(cloneDefaultActionDescriptor);
110
+ }
111
+ function shouldMergeDefaultPopup(popup) {
112
+ if (!import_lodash.default.isPlainObject(popup)) {
113
+ return true;
114
+ }
115
+ const keys = Object.keys(popup);
116
+ if (!keys.length) {
117
+ return true;
118
+ }
119
+ return keys.every((key) => ["mode", "size", "title", "defaultType", "tryTemplate"].includes(key));
120
+ }
121
+ function mergeExplicitActionWithDescriptor(item, descriptor) {
122
+ if (!descriptor.popup || !shouldMergeDefaultPopup(item == null ? void 0 : item.popup)) {
123
+ return item;
124
+ }
125
+ return {
126
+ ...item,
127
+ popup: import_lodash.default.isPlainObject(item == null ? void 0 : item.popup) ? {
128
+ ...import_lodash.default.cloneDeep(descriptor.popup),
129
+ ...import_lodash.default.cloneDeep(item.popup)
130
+ } : import_lodash.default.cloneDeep(descriptor.popup)
131
+ };
132
+ }
133
+ function mergeDefaultActionList(existing, descriptors, createAction) {
134
+ const existingList = Array.isArray(existing) ? existing : [];
135
+ if (!descriptors.length) {
136
+ return [...existingList];
137
+ }
138
+ const defaultTypes = new Set(descriptors.map((descriptor) => descriptor.type));
139
+ const explicitByType = /* @__PURE__ */ new Map();
140
+ const extras = [];
141
+ for (const item of existingList) {
142
+ const type = normalizeActionType(item == null ? void 0 : item.type);
143
+ if (!type || !defaultTypes.has(type)) {
144
+ extras.push(item);
145
+ continue;
146
+ }
147
+ if (!explicitByType.has(type)) {
148
+ explicitByType.set(type, item);
149
+ continue;
150
+ }
151
+ extras.push(item);
152
+ }
153
+ return [
154
+ ...descriptors.map((descriptor) => {
155
+ const explicit = explicitByType.get(descriptor.type);
156
+ return explicit ? mergeExplicitActionWithDescriptor(explicit, descriptor) : createAction(descriptor);
157
+ }),
158
+ ...extras
159
+ ];
160
+ }
161
+ function getFlowSurfaceDefaultBlockActions(input) {
162
+ return resolveDefaultBlockActions(input.blockType, input.template);
163
+ }
164
+ function mergeFlowSurfaceDefaultBlockActions(input) {
165
+ const descriptors = resolveDefaultBlockActions(input.blockType, input.template);
166
+ const actionDescriptors = descriptors.filter((descriptor) => descriptor.scope === "actions");
167
+ const recordActionDescriptors = descriptors.filter((descriptor) => descriptor.scope === "recordActions");
168
+ return {
169
+ actions: mergeDefaultActionList(input.actions, actionDescriptors, input.createAction),
170
+ recordActions: mergeDefaultActionList(input.recordActions, recordActionDescriptors, input.createAction)
171
+ };
172
+ }
173
+ // Annotate the CommonJS export names for ESM import in node:
174
+ 0 && (module.exports = {
175
+ FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY,
176
+ getFlowSurfaceDefaultBlockActions,
177
+ mergeFlowSurfaceDefaultBlockActions
178
+ });
@@ -66,10 +66,10 @@ export type NormalizedComposeFieldSpec = {
66
66
  };
67
67
  export declare function normalizeComposeFieldSpec(input: any, index: number): NormalizedComposeFieldSpec;
68
68
  export declare function normalizeComposeActionSpec(input: any, index: number): {
69
+ popup?: any;
69
70
  key: string;
70
71
  type: string;
71
72
  settings: any;
72
- popup: any;
73
73
  };
74
74
  export declare function normalizeSimpleResourceInit(input: any): _.Dictionary<any>;
75
75
  export declare function isMissingRequiredResourceInitValue(value: any): boolean;
@@ -346,8 +346,7 @@ function normalizeComposeActionSpec(input, index) {
346
346
  return {
347
347
  key: type2,
348
348
  type: type2,
349
- settings: {},
350
- popup: void 0
349
+ settings: {}
351
350
  };
352
351
  }
353
352
  if (!import_lodash.default.isPlainObject(input)) {
@@ -367,11 +366,12 @@ function normalizeComposeActionSpec(input, index) {
367
366
  String(input.key || type).trim(),
368
367
  `flowSurfaces compose action #${index + 1}`
369
368
  );
369
+ const popup = import_lodash.default.isPlainObject(input.popup) ? input.popup : void 0;
370
370
  return {
371
371
  key,
372
372
  type,
373
373
  settings: import_lodash.default.isPlainObject(input.settings) ? input.settings : {},
374
- popup: import_lodash.default.isPlainObject(input.popup) ? input.popup : void 0
374
+ ...popup ? { popup } : {}
375
375
  };
376
376
  }
377
377
  function normalizeSimpleResourceInit(input) {
@@ -39,6 +39,7 @@ export declare class FlowSurfacesService {
39
39
  get locator(): SurfaceLocator;
40
40
  private get routeSync();
41
41
  private getFlowTemplateRepository;
42
+ private getFlowTemplateRepositorySafe;
42
43
  private getFlowTemplateUsageRepository;
43
44
  private getFlowTemplateUsageModel;
44
45
  private getFlowTemplateUsageRepositorySafe;
@@ -358,6 +359,7 @@ export declare class FlowSurfacesService {
358
359
  transaction?: any;
359
360
  deferAutoLayout?: boolean;
360
361
  enabledPackages?: ReadonlySet<string>;
362
+ skipDefaultBlockActions?: boolean;
361
363
  }): any;
362
364
  addField(values: Record<string, any>, options?: {
363
365
  transaction?: any;
@@ -424,6 +426,13 @@ export declare class FlowSurfacesService {
424
426
  private hasInlinePopupSaveAsTemplateSource;
425
427
  private assertInlinePopupSaveAsTemplateSource;
426
428
  private clearPopupSurfaceKeys;
429
+ private buildLegacyAutoGeneratedPopupTemplateMetadata;
430
+ private formatAutoGeneratedPopupTemplateMetadata;
431
+ private formatAutoGeneratedActionPopupTemplateMetadata;
432
+ private resolveFieldBindingContext;
433
+ private resolveAutoGeneratedFieldPopupTemplateMetadata;
434
+ private shouldAutoSaveDefaultActionPopupTemplate;
435
+ private resolveAutoGeneratedActionPopupTemplateMetadata;
427
436
  private savePopupAsTemplate;
428
437
  private buildInlinePopupTemplateOpenView;
429
438
  private peekInlineFieldSettingsOpenView;
@@ -437,6 +446,7 @@ export declare class FlowSurfacesService {
437
446
  private getPopupTryTemplateExpectedAssociationName;
438
447
  private getPopupTryTemplatePriority;
439
448
  private getRequestedPopupDefaultType;
449
+ private getPopupTryTemplateAllowedDefaultTypes;
440
450
  private inferPopupDefaultTypeFromTemplateTree;
441
451
  private popupTemplateMatchesDefaultType;
442
452
  private tryResolvePopupTemplateForHost;
@@ -466,6 +476,7 @@ export declare class FlowSurfacesService {
466
476
  private buildDefaultFieldPopupFieldPaths;
467
477
  private buildDefaultFieldPopupBlocks;
468
478
  private autoSaveDefaultFieldPopupAsTemplate;
479
+ private autoSaveDefaultActionPopupAsTemplate;
469
480
  private shouldAutoCompleteDefaultActionPopup;
470
481
  private buildDefaultActionPopupFieldPaths;
471
482
  private buildDefaultActionPopupNamespace;
@@ -589,6 +600,10 @@ export declare class FlowSurfacesService {
589
600
  private inspectRecordActionContainer;
590
601
  private materializeRecordActionContainer;
591
602
  private runBatchCreate;
603
+ private buildInjectedComposeDefaultActionSpec;
604
+ private normalizeComposeFieldsLayout;
605
+ private normalizeComposeFieldsLayoutCell;
606
+ private applyDefaultActionsForCreatedBlock;
592
607
  private normalizeComposeBlock;
593
608
  private normalizeComposeBlocks;
594
609
  private resolveComposeActionContainerUid;
@@ -651,6 +666,7 @@ export declare class FlowSurfacesService {
651
666
  private buildFilterFormTargetPaths;
652
667
  private getEditableDomains;
653
668
  private resolveContextSemantic;
669
+ private resolveRecordActionContextOwner;
654
670
  private loadContextAncestorChain;
655
671
  private resolveCollectionFromInit;
656
672
  private buildChartContextSemantic;