@nocobase/plugin-flow-engine 2.1.0-beta.23 → 2.1.0-beta.25

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.
Files changed (39) hide show
  1. package/dist/ai/ai-employees/nathan/index.js +1 -0
  2. package/dist/externalVersion.js +10 -10
  3. package/dist/node_modules/ses/package.json +1 -1
  4. package/dist/node_modules/zod/package.json +1 -1
  5. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +2 -1
  6. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +142 -22
  7. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +2 -1
  8. package/dist/server/flow-surfaces/blueprint/compile-plan.js +8 -8
  9. package/dist/server/flow-surfaces/blueprint/normalize-document.js +5 -14
  10. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +0 -1
  11. package/dist/server/flow-surfaces/blueprint/private-utils.js +0 -3
  12. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +1 -1
  13. package/dist/server/flow-surfaces/builder.d.ts +1 -0
  14. package/dist/server/flow-surfaces/builder.js +167 -53
  15. package/dist/server/flow-surfaces/catalog.js +59 -3
  16. package/dist/server/flow-surfaces/compose-compiler.d.ts +0 -1
  17. package/dist/server/flow-surfaces/compose-compiler.js +0 -1
  18. package/dist/server/flow-surfaces/configure-options.js +4 -4
  19. package/dist/server/flow-surfaces/contract-guard.js +11 -3
  20. package/dist/server/flow-surfaces/default-block-actions.js +11 -10
  21. package/dist/server/flow-surfaces/field-type-resolver.d.ts +0 -1
  22. package/dist/server/flow-surfaces/field-type-resolver.js +3 -13
  23. package/dist/server/flow-surfaces/hidden-popup-calendar.d.ts +86 -0
  24. package/dist/server/flow-surfaces/hidden-popup-calendar.js +554 -0
  25. package/dist/server/flow-surfaces/hidden-popup-contract.d.ts +116 -0
  26. package/dist/server/flow-surfaces/hidden-popup-contract.js +611 -0
  27. package/dist/server/flow-surfaces/hidden-popup-kanban.d.ts +62 -0
  28. package/dist/server/flow-surfaces/hidden-popup-kanban.js +651 -0
  29. package/dist/server/flow-surfaces/placement.js +1 -0
  30. package/dist/server/flow-surfaces/public-compatibility.d.ts +28 -0
  31. package/dist/server/flow-surfaces/public-compatibility.js +161 -0
  32. package/dist/server/flow-surfaces/service-utils.d.ts +0 -1
  33. package/dist/server/flow-surfaces/service-utils.js +0 -6
  34. package/dist/server/flow-surfaces/service.d.ts +66 -10
  35. package/dist/server/flow-surfaces/service.js +1677 -795
  36. package/dist/swagger/flow-surfaces.d.ts +0 -29
  37. package/dist/swagger/flow-surfaces.js +8 -17
  38. package/dist/swagger/index.d.ts +0 -29
  39. package/package.json +2 -2
@@ -0,0 +1,651 @@
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 hidden_popup_kanban_exports = {};
38
+ __export(hidden_popup_kanban_exports, {
39
+ KANBAN_BLOCK_POPUP_PROP_KEYS: () => KANBAN_BLOCK_POPUP_PROP_KEYS,
40
+ KANBAN_CARD_POPUP_PROP_KEYS: () => KANBAN_CARD_POPUP_PROP_KEYS,
41
+ KANBAN_POPUP_ACTION_KEYS: () => KANBAN_POPUP_ACTION_KEYS,
42
+ KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY: () => KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY,
43
+ buildKanbanInitialItemProps: () => buildKanbanInitialItemProps,
44
+ buildKanbanInitialItemStepParams: () => buildKanbanInitialItemStepParams,
45
+ buildKanbanInitialStepParams: () => buildKanbanInitialStepParams,
46
+ buildKanbanPopupOpenView: () => buildKanbanPopupOpenView,
47
+ ensureKanbanBlockPopupHosts: () => ensureKanbanBlockPopupHosts,
48
+ getKanbanBlockResourceInit: () => getKanbanBlockResourceInit,
49
+ getKanbanInitialPopupSettings: () => getKanbanInitialPopupSettings,
50
+ getKanbanInitialPopupSettingsFromProps: () => getKanbanInitialPopupSettingsFromProps,
51
+ getKanbanPopupActionUid: () => getKanbanPopupActionUid,
52
+ getKanbanPopupActionUse: () => getKanbanPopupActionUse,
53
+ getKanbanPopupStoredSettings: () => getKanbanPopupStoredSettings,
54
+ mergeKanbanPopupSettings: () => mergeKanbanPopupSettings,
55
+ normalizeKanbanPopupConfigureValue: () => normalizeKanbanPopupConfigureValue,
56
+ normalizeKanbanPopupSettings: () => normalizeKanbanPopupSettings,
57
+ projectKanbanBlockPopupHosts: () => projectKanbanBlockPopupHosts,
58
+ projectKanbanBlockPopupHostsInTree: () => projectKanbanBlockPopupHostsInTree,
59
+ replaceKanbanStoredPopupSettings: () => replaceKanbanStoredPopupSettings,
60
+ resolveKanbanInitialPopupOverride: () => resolveKanbanInitialPopupOverride,
61
+ stripKanbanPopupTargetSettingsForResourceChange: () => stripKanbanPopupTargetSettingsForResourceChange
62
+ });
63
+ module.exports = __toCommonJS(hidden_popup_kanban_exports);
64
+ var import_lodash = __toESM(require("lodash"));
65
+ var import_service_utils = require("./service-utils");
66
+ var import_hidden_popup_contract = require("./hidden-popup-contract");
67
+ const KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY = {
68
+ quickCreateAction: "-quick-create-action",
69
+ cardViewAction: "-card-view-action"
70
+ };
71
+ const KANBAN_POPUP_ACTION_KEYS = Object.keys(KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY);
72
+ const KANBAN_BLOCK_POPUP_PROP_KEYS = [
73
+ "popupMode",
74
+ "popupSize",
75
+ "popupTemplateUid",
76
+ "popupPageModelClass",
77
+ "popupTargetUid",
78
+ "quickCreatePopupSettings"
79
+ ];
80
+ const KANBAN_CARD_POPUP_PROP_KEYS = [
81
+ "openMode",
82
+ "popupSize",
83
+ "popupTemplateUid",
84
+ "pageModelClass",
85
+ "popupTargetUid",
86
+ "cardPopupSettings"
87
+ ];
88
+ const KANBAN_POPUP_PATCH_PATH_BY_ACTION = {
89
+ quickCreateAction: ["kanbanSettings", "popup"],
90
+ cardViewAction: ["cardSettings", "popup"]
91
+ };
92
+ function normalizeKanbanPopupSettings(actionKey, popupSettings, blockUid) {
93
+ const actionUid = blockUid && actionKey ? getKanbanPopupActionUid(blockUid, actionKey) : void 0;
94
+ return (0, import_hidden_popup_contract.normalizeHiddenPopupSettings)(popupSettings, {
95
+ invalidUids: [blockUid, actionUid]
96
+ });
97
+ }
98
+ function getKanbanInitialPopupSettings(actionKey, settings, blockUid) {
99
+ const primaryKey = actionKey === "quickCreateAction" ? "quickCreatePopup" : "cardPopup";
100
+ const legacyKey = actionKey === "quickCreateAction" ? "quickCreatePopupSettings" : "cardPopupSettings";
101
+ const popupSettings = import_lodash.default.isPlainObject(settings == null ? void 0 : settings[primaryKey]) ? settings == null ? void 0 : settings[primaryKey] : import_lodash.default.isPlainObject(settings == null ? void 0 : settings[legacyKey]) ? settings == null ? void 0 : settings[legacyKey] : void 0;
102
+ if (!import_lodash.default.isPlainObject(popupSettings)) {
103
+ return void 0;
104
+ }
105
+ const normalized = normalizeKanbanPopupSettings(actionKey, popupSettings, blockUid);
106
+ return Object.keys(normalized).length ? normalized : void 0;
107
+ }
108
+ function getKanbanInitialPopupSettingsFromProps(actionKey, props, blockUid) {
109
+ if (!import_lodash.default.isPlainObject(props)) {
110
+ return void 0;
111
+ }
112
+ const rawSettings = actionKey === "quickCreateAction" ? (0, import_service_utils.buildDefinedPayload)({
113
+ mode: props.popupMode,
114
+ size: props.popupSize,
115
+ popupTemplateUid: props.popupTemplateUid,
116
+ pageModelClass: props.popupPageModelClass,
117
+ uid: props.popupTargetUid
118
+ }) : (0, import_service_utils.buildDefinedPayload)({
119
+ mode: props.cardOpenMode,
120
+ size: props.cardPopupSize,
121
+ popupTemplateUid: props.cardPopupTemplateUid,
122
+ pageModelClass: props.cardPopupPageModelClass,
123
+ uid: props.cardPopupTargetUid
124
+ });
125
+ const normalized = normalizeKanbanPopupSettings(actionKey, rawSettings, blockUid);
126
+ return Object.keys(normalized).length ? normalized : void 0;
127
+ }
128
+ function getKanbanPopupActionUse(actionKey) {
129
+ return actionKey === "quickCreateAction" ? "KanbanQuickCreateActionModel" : "KanbanCardViewActionModel";
130
+ }
131
+ function getKanbanPopupActionUid(kanbanUid, actionKey) {
132
+ return `${kanbanUid}${KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY[actionKey]}`;
133
+ }
134
+ function getKanbanBlockResourceInit(blockNode) {
135
+ const resourceInit = import_lodash.default.cloneDeep(import_lodash.default.get(blockNode, ["stepParams", "resourceSettings", "init"]) || {});
136
+ if (resourceInit.collectionName && !resourceInit.dataSourceKey) {
137
+ resourceInit.dataSourceKey = "main";
138
+ }
139
+ return resourceInit;
140
+ }
141
+ function buildKanbanInitialStepParams(input) {
142
+ var _a, _b, _c, _d;
143
+ const nextStepParams = import_lodash.default.cloneDeep(input.stepParams || {});
144
+ const initialQuickCreateEnabled = import_lodash.default.isBoolean((_a = input.settings) == null ? void 0 : _a.quickCreateEnabled) ? (_b = input.settings) == null ? void 0 : _b.quickCreateEnabled : import_lodash.default.isBoolean((_c = input.props) == null ? void 0 : _c.quickCreateEnabled) ? (_d = input.props) == null ? void 0 : _d.quickCreateEnabled : void 0;
145
+ if (import_lodash.default.isBoolean(initialQuickCreateEnabled) && !import_lodash.default.has(nextStepParams, ["kanbanSettings", "quickCreate"])) {
146
+ import_lodash.default.set(nextStepParams, ["kanbanSettings", "quickCreate"], {
147
+ quickCreateEnabled: initialQuickCreateEnabled
148
+ });
149
+ }
150
+ const quickCreatePopup = import_lodash.default.has(nextStepParams, ["kanbanSettings", "popup"]) ? import_lodash.default.get(nextStepParams, ["kanbanSettings", "popup"]) : getKanbanInitialPopupSettings("quickCreateAction", input.settings) || getKanbanInitialPopupSettings("quickCreateAction", input.props) || getKanbanInitialPopupSettingsFromProps("quickCreateAction", input.props);
151
+ if (import_lodash.default.isPlainObject(quickCreatePopup)) {
152
+ import_lodash.default.set(nextStepParams, ["kanbanSettings", "popup"], import_lodash.default.cloneDeep(quickCreatePopup));
153
+ }
154
+ const cardPopup = import_lodash.default.has(nextStepParams, ["cardSettings", "popup"]) ? import_lodash.default.get(nextStepParams, ["cardSettings", "popup"]) : getKanbanInitialPopupSettings("cardViewAction", input.settings) || getKanbanInitialPopupSettings("cardViewAction", input.props) || getKanbanInitialPopupSettingsFromProps("cardViewAction", input.props);
155
+ if (import_lodash.default.isPlainObject(cardPopup)) {
156
+ import_lodash.default.set(nextStepParams, ["cardSettings", "popup"], import_lodash.default.cloneDeep(cardPopup));
157
+ }
158
+ return nextStepParams;
159
+ }
160
+ function buildKanbanInitialItemProps(input) {
161
+ var _a, _b, _c, _d;
162
+ const enableCardClick = import_lodash.default.isBoolean((_a = input.settings) == null ? void 0 : _a.enableCardClick) ? (_b = input.settings) == null ? void 0 : _b.enableCardClick : import_lodash.default.isBoolean((_c = input.props) == null ? void 0 : _c.enableCardClick) ? (_d = input.props) == null ? void 0 : _d.enableCardClick : void 0;
163
+ return (0, import_service_utils.buildDefinedPayload)({
164
+ ...import_lodash.default.isBoolean(enableCardClick) ? { enableCardClick } : {}
165
+ });
166
+ }
167
+ function buildKanbanInitialItemStepParams(input) {
168
+ var _a, _b, _c, _d;
169
+ const nextStepParams = import_lodash.default.cloneDeep(input.stepParams || {});
170
+ const enableCardClick = import_lodash.default.isBoolean((_a = input.settings) == null ? void 0 : _a.enableCardClick) ? (_b = input.settings) == null ? void 0 : _b.enableCardClick : import_lodash.default.isBoolean((_c = input.props) == null ? void 0 : _c.enableCardClick) ? (_d = input.props) == null ? void 0 : _d.enableCardClick : void 0;
171
+ if (import_lodash.default.isBoolean(enableCardClick) && !import_lodash.default.has(nextStepParams, ["cardSettings", "click"])) {
172
+ import_lodash.default.set(nextStepParams, ["cardSettings", "click"], {
173
+ enableCardClick
174
+ });
175
+ }
176
+ const cardPopup = import_lodash.default.has(nextStepParams, ["cardSettings", "popup"]) ? import_lodash.default.get(nextStepParams, ["cardSettings", "popup"]) : getKanbanInitialPopupSettings("cardViewAction", input.settings) || getKanbanInitialPopupSettings("cardViewAction", input.props) || getKanbanInitialPopupSettingsFromProps("cardViewAction", input.props);
177
+ if (import_lodash.default.isPlainObject(cardPopup)) {
178
+ import_lodash.default.set(nextStepParams, ["cardSettings", "popup"], import_lodash.default.cloneDeep(cardPopup));
179
+ }
180
+ return nextStepParams;
181
+ }
182
+ function getKanbanPopupStoredSettings(blockNode, actionKey) {
183
+ var _a;
184
+ const itemNode = (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode == null ? void 0 : blockNode.subModels) == null ? void 0 : _a.item);
185
+ const rawPopupSettings = (() => {
186
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
187
+ if (actionKey === "quickCreateAction") {
188
+ if (import_lodash.default.has(blockNode, ["stepParams", "kanbanSettings", "popup"])) {
189
+ const settings = import_lodash.default.get(blockNode, ["stepParams", "kanbanSettings", "popup"]);
190
+ return import_lodash.default.isPlainObject(settings) ? settings : {};
191
+ }
192
+ return (0, import_service_utils.buildDefinedPayload)({
193
+ mode: (_a2 = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _a2.popupMode,
194
+ size: (_b = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _b.popupSize,
195
+ popupTemplateUid: (_c = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _c.popupTemplateUid,
196
+ pageModelClass: (_d = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _d.popupPageModelClass,
197
+ uid: (_e = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _e.popupTargetUid
198
+ });
199
+ }
200
+ if (import_lodash.default.has(itemNode, ["stepParams", "cardSettings", "popup"])) {
201
+ const settings = import_lodash.default.get(itemNode, ["stepParams", "cardSettings", "popup"]);
202
+ return import_lodash.default.isPlainObject(settings) ? settings : {};
203
+ }
204
+ return (0, import_service_utils.buildDefinedPayload)({
205
+ mode: (_f = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _f.openMode,
206
+ size: (_g = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _g.popupSize,
207
+ popupTemplateUid: (_h = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _h.popupTemplateUid,
208
+ pageModelClass: (_i = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _i.pageModelClass,
209
+ uid: (_j = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _j.popupTargetUid
210
+ });
211
+ })();
212
+ return normalizeKanbanPopupSettings(actionKey, rawPopupSettings, blockNode == null ? void 0 : blockNode.uid);
213
+ }
214
+ function buildKanbanPopupOpenView(input) {
215
+ const actionUid = getKanbanPopupActionUid(input.blockNode.uid, input.actionKey);
216
+ const resourceInit = input.resourceInit || getKanbanBlockResourceInit(input.blockNode);
217
+ return (0, import_hidden_popup_contract.buildHiddenPopupOpenView)({
218
+ actionUid,
219
+ resourceInit,
220
+ popupSettings: input.popupSettings ? input.popupSettings : getKanbanPopupStoredSettings(input.blockNode, input.actionKey),
221
+ normalizePopupSettings: (popupSettings) => normalizeKanbanPopupSettings(input.actionKey, popupSettings, input.blockNode.uid)
222
+ });
223
+ }
224
+ async function normalizeKanbanPopupConfigureValue(input) {
225
+ if (import_lodash.default.isUndefined(input.value)) {
226
+ return void 0;
227
+ }
228
+ if (import_lodash.default.isNull(input.value)) {
229
+ return {};
230
+ }
231
+ const actionUid = getKanbanPopupActionUid(input.blockUid, input.actionKey);
232
+ const normalized = await input.normalizeOpenView(input.actionName, input.value, {
233
+ transaction: input.transaction,
234
+ popupTemplateHostUid: actionUid,
235
+ popupActionContext: {
236
+ hasCurrentRecord: input.actionKey === "cardViewAction"
237
+ }
238
+ });
239
+ return normalizeKanbanPopupSettings(
240
+ input.actionKey,
241
+ {
242
+ ...normalized || {},
243
+ ...import_lodash.default.isPlainObject(input.value) && input.value.tryTemplate === false ? { tryTemplate: false } : {}
244
+ },
245
+ input.blockUid
246
+ );
247
+ }
248
+ function resolveKanbanInitialPopupOverride(settings, primaryKey, legacyKey) {
249
+ if (!import_lodash.default.isPlainObject(settings)) {
250
+ return void 0;
251
+ }
252
+ if (import_lodash.default.isPlainObject(settings[primaryKey])) {
253
+ return settings[primaryKey];
254
+ }
255
+ if (import_lodash.default.isPlainObject(settings[legacyKey])) {
256
+ return settings[legacyKey];
257
+ }
258
+ return void 0;
259
+ }
260
+ function mergeKanbanPopupSettings(actionKey, current, value, blockUid) {
261
+ if (!import_lodash.default.isPlainObject(value)) {
262
+ return {};
263
+ }
264
+ const currentBase = import_lodash.default.isPlainObject(current) && (0, import_hidden_popup_contract.hasExplicitHiddenPopupTargetSettings)(value) ? import_lodash.default.pick(import_lodash.default.cloneDeep(current), import_hidden_popup_contract.HIDDEN_POPUP_DISPLAY_KEYS) : current;
265
+ const merged = import_lodash.default.isPlainObject(currentBase) ? { ...import_lodash.default.cloneDeep(currentBase), ...import_lodash.default.cloneDeep(value) } : value;
266
+ return normalizeKanbanPopupSettings(actionKey, merged, blockUid);
267
+ }
268
+ function stripKanbanPopupTargetSettingsForResourceChange(actionKey, popupSettings, blockUid) {
269
+ return normalizeKanbanPopupSettings(
270
+ actionKey,
271
+ (0, import_hidden_popup_contract.stripHiddenPopupTargetSettings)(popupSettings, { disableTemplateAutoBind: true }),
272
+ blockUid
273
+ );
274
+ }
275
+ async function replaceKanbanStoredPopupSettings(runtime, blockNode, actionKey, popupSettings, transaction) {
276
+ var _a;
277
+ const targetNode = actionKey === "quickCreateAction" ? blockNode : (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode == null ? void 0 : blockNode.subModels) == null ? void 0 : _a.item);
278
+ if (!(targetNode == null ? void 0 : targetNode.uid)) {
279
+ return;
280
+ }
281
+ const path = KANBAN_POPUP_PATCH_PATH_BY_ACTION[actionKey];
282
+ const nextStepParams = import_lodash.default.cloneDeep(targetNode.stepParams || {});
283
+ if (Object.keys(popupSettings || {}).length) {
284
+ import_lodash.default.set(nextStepParams, path, import_lodash.default.cloneDeep(popupSettings));
285
+ } else {
286
+ (0, import_hidden_popup_contract.unsetHiddenPopupPayloadPathAndPruneEmptyParents)(nextStepParams, path);
287
+ }
288
+ if (import_lodash.default.isEqual(nextStepParams, targetNode.stepParams || {})) {
289
+ return;
290
+ }
291
+ await runtime.repository.patch(
292
+ {
293
+ uid: targetNode.uid,
294
+ stepParams: nextStepParams
295
+ },
296
+ { transaction }
297
+ );
298
+ targetNode.stepParams = nextStepParams;
299
+ }
300
+ async function persistKanbanPopupSettingsFromOpenView(runtime, blockNode, actionKey, openView, popupSettings, transaction) {
301
+ const storedSettings = (0, import_hidden_popup_contract.buildPersistedHiddenPopupSettingsFromOpenView)({
302
+ openView,
303
+ popupSettings,
304
+ expectedHostUid: getKanbanPopupActionUid(blockNode.uid, actionKey),
305
+ normalizePopupSettings: (settings) => normalizeKanbanPopupSettings(actionKey, settings, blockNode == null ? void 0 : blockNode.uid)
306
+ });
307
+ await replaceKanbanStoredPopupSettings(runtime, blockNode, actionKey, storedSettings, transaction);
308
+ }
309
+ function mergeKanbanPopupDisplaySettings(actionKey, openView, popupSettings, fallbackOpenView, options = {}) {
310
+ return (0, import_hidden_popup_contract.mergeHiddenPopupDisplaySettings)({
311
+ openView,
312
+ popupSettings,
313
+ fallbackOpenView,
314
+ normalizePopupSettings: (settings) => normalizeKanbanPopupSettings(actionKey, settings),
315
+ preserveOpenViewDisplay: options.preserveOpenViewDisplay,
316
+ preserveOpenViewDisplayFallback: options.preserveOpenViewDisplayFallback
317
+ });
318
+ }
319
+ async function buildKanbanPopupOpenViewWithTemplate(runtime, input) {
320
+ var _a, _b;
321
+ const actionUid = getKanbanPopupActionUid(input.blockNode.uid, input.actionKey);
322
+ const openView = buildKanbanPopupOpenView(input);
323
+ return runtime.buildPopupOpenViewWithTemplate({
324
+ actionName: `kanban ${input.actionKey}`,
325
+ actionUid,
326
+ openView,
327
+ popupSettings: input.popupSettings,
328
+ existingHost: (0, import_service_utils.getSingleNodeSubModel)((_b = (_a = input.blockNode) == null ? void 0 : _a.subModels) == null ? void 0 : _b[input.actionKey]),
329
+ transaction: input.transaction,
330
+ hasCurrentRecord: input.actionKey === "cardViewAction",
331
+ normalizePopupSettings: (popupSettings) => normalizeKanbanPopupSettings(input.actionKey, popupSettings, input.blockNode.uid),
332
+ mergeDisplaySettings: (nextOpenView, popupSettings, fallbackOpenView) => mergeKanbanPopupDisplaySettings(input.actionKey, nextOpenView, popupSettings, fallbackOpenView)
333
+ });
334
+ }
335
+ async function resolveKanbanPopupOpenViewWithFallback(runtime, input) {
336
+ const baseOpenView = buildKanbanPopupOpenView(input);
337
+ const openView = await buildKanbanPopupOpenViewWithTemplate(runtime, input);
338
+ return mergeKanbanPopupDisplaySettings(input.actionKey, openView, input.popupSettings, baseOpenView);
339
+ }
340
+ async function ensureKanbanPopupHostDefaultContent(runtime, input) {
341
+ return runtime.ensurePopupHostDefaultContent({
342
+ actionName: `kanban ${input.actionKey}`,
343
+ actionUid: input.actionUid,
344
+ popupSettings: input.popupSettings,
345
+ transaction: input.transaction,
346
+ hasCurrentRecord: input.actionKey === "cardViewAction",
347
+ mergeDisplaySettings: (openView, popupSettings, fallbackOpenView) => mergeKanbanPopupDisplaySettings(input.actionKey, openView, popupSettings, fallbackOpenView)
348
+ });
349
+ }
350
+ async function ensureKanbanBlockPopupHosts(runtime, blockNode, transaction, popupSettingsOverrides, options = {}) {
351
+ var _a, _b;
352
+ if (!(blockNode == null ? void 0 : blockNode.uid) || blockNode.use !== "KanbanBlockModel") {
353
+ return blockNode;
354
+ }
355
+ const resourceInit = getKanbanBlockResourceInit(blockNode);
356
+ let changed = false;
357
+ for (const actionKey of KANBAN_POPUP_ACTION_KEYS) {
358
+ let existing = (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode.subModels) == null ? void 0 : _a[actionKey]);
359
+ const expectedUid = getKanbanPopupActionUid(blockNode.uid, actionKey);
360
+ const expectedUse = getKanbanPopupActionUse(actionKey);
361
+ const popupSettingsOverride = (0, import_hidden_popup_contract.resolveHiddenPopupSettingsOverride)(popupSettingsOverrides, actionKey);
362
+ const popupSettings = popupSettingsOverride ?? getKanbanPopupStoredSettings(blockNode, actionKey);
363
+ const explicitPopupSettingsProvided = !!popupSettingsOverrides && Object.prototype.hasOwnProperty.call(popupSettingsOverrides, actionKey);
364
+ const seedOpenView = buildKanbanPopupOpenView({
365
+ blockNode,
366
+ actionKey,
367
+ resourceInit,
368
+ popupSettings
369
+ });
370
+ const displayFallbackOpenView = ((_b = options.displayFallbackOpenViews) == null ? void 0 : _b[actionKey]) || seedOpenView;
371
+ const shouldReplaceExisting = (existing == null ? void 0 : existing.uid) && existing.uid !== expectedUid;
372
+ if (!(existing == null ? void 0 : existing.uid) || shouldReplaceExisting || existing.use !== expectedUse) {
373
+ if (shouldReplaceExisting) {
374
+ await runtime.removeNodeTreeWithBindings(existing.uid, transaction);
375
+ }
376
+ await runtime.repository.upsertModel(
377
+ {
378
+ parentId: blockNode.uid,
379
+ subKey: actionKey,
380
+ subType: "object",
381
+ ...(existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
382
+ uid: expectedUid,
383
+ use: expectedUse,
384
+ stepParams: (0, import_hidden_popup_contract.buildHiddenPopupActionStepParams)(
385
+ (existing == null ? void 0 : existing.uid) === expectedUid ? existing.stepParams : {},
386
+ seedOpenView
387
+ )
388
+ },
389
+ { transaction }
390
+ );
391
+ existing = await runtime.repository.findModelById(expectedUid, {
392
+ transaction,
393
+ includeAsyncNode: true
394
+ });
395
+ if (String((seedOpenView == null ? void 0 : seedOpenView.popupTemplateUid) || "").trim()) {
396
+ await runtime.clearFlowTemplateUsagesForNodeTree(expectedUid, transaction);
397
+ await runtime.syncFlowTemplateUsagesForNodeTree(expectedUid, transaction);
398
+ }
399
+ changed = true;
400
+ }
401
+ const hasLocalPopupContent = (0, import_hidden_popup_contract.hiddenPopupHostHasLocalContent)(existing);
402
+ const currentOpenView = (0, import_hidden_popup_contract.resolveHiddenPopupHostOpenView)(existing);
403
+ const normalizedCurrentOpenView = normalizeKanbanPopupSettings(actionKey, currentOpenView, blockNode.uid);
404
+ const popupOpenViewTransition = await (0, import_hidden_popup_contract.resolveHiddenPopupOpenViewTransitionWithCandidate)({
405
+ existing,
406
+ expectedUid,
407
+ expectedUse,
408
+ popupSettings,
409
+ seedOpenView,
410
+ currentOpenView,
411
+ normalizedCurrentOpenView,
412
+ displayFallbackOpenView,
413
+ allowResourceMismatchRebuild: explicitPopupSettingsProvided,
414
+ mergeDisplaySettings: (openView2, popupSettings2, fallbackOpenView, mergeOptions) => mergeKanbanPopupDisplaySettings(actionKey, openView2, popupSettings2, fallbackOpenView, mergeOptions),
415
+ resolveCandidateOpenView: () => resolveKanbanPopupOpenViewWithFallback(runtime, {
416
+ blockNode,
417
+ actionKey,
418
+ resourceInit,
419
+ popupSettings,
420
+ transaction
421
+ })
422
+ });
423
+ const { openView } = popupOpenViewTransition;
424
+ const shouldUpsert = !(existing == null ? void 0 : existing.uid) || existing.use !== expectedUse || !hasLocalPopupContent && !import_lodash.default.isEqual(currentOpenView, openView) || explicitPopupSettingsProvided && !import_lodash.default.isEqual(currentOpenView, openView);
425
+ if (shouldUpsert) {
426
+ if ((existing == null ? void 0 : existing.uid) && existing.uid === expectedUid && !import_lodash.default.isEqual(currentOpenView, openView)) {
427
+ await runtime.reconcilePopupOpenViewTransition(expectedUid, currentOpenView, openView, transaction);
428
+ }
429
+ const shouldRefreshTemplateUsages = !import_lodash.default.isEqual(currentOpenView, openView);
430
+ const nextActionNode = {
431
+ ...(existing == null ? void 0 : existing.uid) && existing.uid === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
432
+ uid: expectedUid,
433
+ use: expectedUse,
434
+ stepParams: (0, import_hidden_popup_contract.buildHiddenPopupActionStepParams)(
435
+ (existing == null ? void 0 : existing.uid) === expectedUid ? existing.stepParams : {},
436
+ openView
437
+ )
438
+ };
439
+ await runtime.repository.upsertModel(
440
+ {
441
+ parentId: blockNode.uid,
442
+ subKey: actionKey,
443
+ subType: "object",
444
+ ...nextActionNode
445
+ },
446
+ { transaction }
447
+ );
448
+ if (shouldRefreshTemplateUsages || String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim()) {
449
+ await runtime.clearFlowTemplateUsagesForNodeTree(expectedUid, transaction);
450
+ if (String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim()) {
451
+ await runtime.syncFlowTemplateUsagesForNodeTree(expectedUid, transaction);
452
+ }
453
+ }
454
+ changed = true;
455
+ }
456
+ const completedDefaultContent = await ensureKanbanPopupHostDefaultContent(runtime, {
457
+ actionKey,
458
+ actionUid: expectedUid,
459
+ popupSettings,
460
+ transaction
461
+ });
462
+ if (completedDefaultContent) {
463
+ existing = await runtime.repository.findModelById(expectedUid, {
464
+ transaction,
465
+ includeAsyncNode: true
466
+ });
467
+ }
468
+ const finalOpenView = completedDefaultContent ? (0, import_hidden_popup_contract.resolveHiddenPopupHostOpenView)(existing) : openView;
469
+ await persistKanbanPopupSettingsFromOpenView(
470
+ runtime,
471
+ blockNode,
472
+ actionKey,
473
+ finalOpenView,
474
+ popupSettings,
475
+ transaction
476
+ );
477
+ if (existing == null ? void 0 : existing.uid) {
478
+ blockNode.subModels = {
479
+ ...blockNode.subModels || {},
480
+ [actionKey]: existing
481
+ };
482
+ }
483
+ changed = completedDefaultContent || changed;
484
+ }
485
+ if (!changed) {
486
+ return blockNode;
487
+ }
488
+ const refreshed = await runtime.repository.findModelById(blockNode.uid, {
489
+ transaction,
490
+ includeAsyncNode: true
491
+ });
492
+ if (refreshed == null ? void 0 : refreshed.uid) {
493
+ return refreshed;
494
+ }
495
+ return blockNode;
496
+ }
497
+ function projectKanbanBlockPopupHosts(node) {
498
+ var _a;
499
+ if (!node || typeof node !== "object") {
500
+ return node;
501
+ }
502
+ const current = node;
503
+ if (!(current == null ? void 0 : current.uid) || current.use !== "KanbanBlockModel") {
504
+ return node;
505
+ }
506
+ const resourceInit = getKanbanBlockResourceInit(current);
507
+ let nextSubModels = current.subModels;
508
+ let changed = false;
509
+ for (const actionKey of KANBAN_POPUP_ACTION_KEYS) {
510
+ const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = current.subModels) == null ? void 0 : _a[actionKey]);
511
+ const expectedUid = getKanbanPopupActionUid(current.uid, actionKey);
512
+ const expectedUse = getKanbanPopupActionUse(actionKey);
513
+ const popupSettings = getKanbanPopupStoredSettings(current, actionKey);
514
+ const persistedOpenView = (0, import_hidden_popup_contract.resolveHiddenPopupHostOpenView)(existing);
515
+ const seedOpenView = buildKanbanPopupOpenView({
516
+ blockNode: current,
517
+ actionKey,
518
+ resourceInit,
519
+ popupSettings
520
+ });
521
+ const currentOpenView = (0, import_hidden_popup_contract.resolveHiddenPopupHostOpenView)(existing);
522
+ const normalizedCurrentOpenView = normalizeKanbanPopupSettings(actionKey, currentOpenView, current.uid);
523
+ const { openView } = (0, import_hidden_popup_contract.resolveHiddenPopupOpenViewTransition)({
524
+ existing,
525
+ expectedUid,
526
+ expectedUse,
527
+ popupSettings,
528
+ seedOpenView,
529
+ candidateOpenView: seedOpenView,
530
+ currentOpenView,
531
+ normalizedCurrentOpenView,
532
+ preservedOpenView: persistedOpenView,
533
+ resourceMismatchDisplayFallbackOpenView: (0, import_hidden_popup_contract.buildHiddenPopupResourceMismatchDisplayFallbackOpenView)({
534
+ normalizedCurrentOpenView,
535
+ resourceInit,
536
+ popupSettings,
537
+ stripPopupTargetSettingsForResourceChange: (popupSettings2) => stripKanbanPopupTargetSettingsForResourceChange(actionKey, popupSettings2, current.uid),
538
+ buildOpenView: ({ resourceInit: resourceInit2, popupSettings: popupSettings2 }) => buildKanbanPopupOpenView({
539
+ blockNode: current,
540
+ actionKey,
541
+ resourceInit: resourceInit2,
542
+ popupSettings: popupSettings2
543
+ })
544
+ }),
545
+ allowResourceMismatchRebuild: true,
546
+ mergeDisplaySettings: (openView2, popupSettings2, fallbackOpenView, mergeOptions) => mergeKanbanPopupDisplaySettings(actionKey, openView2, popupSettings2, fallbackOpenView, mergeOptions)
547
+ });
548
+ if ((existing == null ? void 0 : existing.uid) === expectedUid && existing.use === expectedUse && import_lodash.default.isEqual(currentOpenView, openView)) {
549
+ continue;
550
+ }
551
+ const nextActionNode = {
552
+ ...(existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
553
+ uid: expectedUid,
554
+ use: expectedUse,
555
+ stepParams: (0, import_hidden_popup_contract.buildHiddenPopupActionStepParams)((existing == null ? void 0 : existing.uid) === expectedUid ? existing.stepParams : {}, openView)
556
+ };
557
+ if (!changed) {
558
+ nextSubModels = {
559
+ ...current.subModels || {}
560
+ };
561
+ changed = true;
562
+ }
563
+ nextSubModels[actionKey] = nextActionNode;
564
+ }
565
+ if (!changed) {
566
+ return node;
567
+ }
568
+ return {
569
+ ...current,
570
+ subModels: nextSubModels
571
+ };
572
+ }
573
+ function projectKanbanBlockPopupHostsInTree(node) {
574
+ if (!node || typeof node !== "object") {
575
+ return node;
576
+ }
577
+ let current = projectKanbanBlockPopupHosts(node);
578
+ let nextSubModels = current == null ? void 0 : current.subModels;
579
+ let changed = current !== node;
580
+ if (!nextSubModels || typeof nextSubModels !== "object") {
581
+ return current;
582
+ }
583
+ for (const [subKey, value] of Object.entries(nextSubModels)) {
584
+ if (Array.isArray(value)) {
585
+ const nextItems = [];
586
+ let itemsChanged = false;
587
+ for (const item of value) {
588
+ const nextItem = projectKanbanBlockPopupHostsInTree(item);
589
+ nextItems.push(nextItem);
590
+ itemsChanged = itemsChanged || nextItem !== item;
591
+ }
592
+ if (!itemsChanged) {
593
+ continue;
594
+ }
595
+ if (!changed) {
596
+ current = {
597
+ ...current,
598
+ subModels: {
599
+ ...nextSubModels
600
+ }
601
+ };
602
+ nextSubModels = current.subModels;
603
+ changed = true;
604
+ }
605
+ nextSubModels[subKey] = nextItems;
606
+ continue;
607
+ }
608
+ const nextValue = projectKanbanBlockPopupHostsInTree(value);
609
+ if (nextValue === value) {
610
+ continue;
611
+ }
612
+ if (!changed) {
613
+ current = {
614
+ ...current,
615
+ subModels: {
616
+ ...nextSubModels
617
+ }
618
+ };
619
+ nextSubModels = current.subModels;
620
+ changed = true;
621
+ }
622
+ nextSubModels[subKey] = nextValue;
623
+ }
624
+ return current;
625
+ }
626
+ // Annotate the CommonJS export names for ESM import in node:
627
+ 0 && (module.exports = {
628
+ KANBAN_BLOCK_POPUP_PROP_KEYS,
629
+ KANBAN_CARD_POPUP_PROP_KEYS,
630
+ KANBAN_POPUP_ACTION_KEYS,
631
+ KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY,
632
+ buildKanbanInitialItemProps,
633
+ buildKanbanInitialItemStepParams,
634
+ buildKanbanInitialStepParams,
635
+ buildKanbanPopupOpenView,
636
+ ensureKanbanBlockPopupHosts,
637
+ getKanbanBlockResourceInit,
638
+ getKanbanInitialPopupSettings,
639
+ getKanbanInitialPopupSettingsFromProps,
640
+ getKanbanPopupActionUid,
641
+ getKanbanPopupActionUse,
642
+ getKanbanPopupStoredSettings,
643
+ mergeKanbanPopupSettings,
644
+ normalizeKanbanPopupConfigureValue,
645
+ normalizeKanbanPopupSettings,
646
+ projectKanbanBlockPopupHosts,
647
+ projectKanbanBlockPopupHostsInTree,
648
+ replaceKanbanStoredPopupSettings,
649
+ resolveKanbanInitialPopupOverride,
650
+ stripKanbanPopupTargetSettingsForResourceChange
651
+ });
@@ -56,6 +56,7 @@ const FLOW_SURFACE_POPUP_HOST_USES = /* @__PURE__ */ new Set([
56
56
  "ViewActionModel",
57
57
  "EditActionModel",
58
58
  "PopupCollectionActionModel",
59
+ "AddChildActionModel",
59
60
  "CalendarQuickCreateActionModel",
60
61
  "CalendarEventViewActionModel",
61
62
  "KanbanQuickCreateActionModel",