@nocobase/flow-engine 2.2.0-beta.9 → 2.2.0
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/acl/Acl.d.ts +2 -1
- package/lib/acl/Acl.js +28 -0
- package/lib/components/FlowContextSelector.js +62 -13
- package/lib/components/FormItem.js +11 -7
- package/lib/components/MobilePopup.js +39 -10
- package/lib/components/MobilePopup.style.js +11 -1
- package/lib/components/subModel/LazyDropdown.js +62 -33
- package/lib/components/variables/VariableHybridInput.d.ts +9 -0
- package/lib/components/variables/VariableHybridInput.js +146 -17
- package/lib/components/variables/VariableInput.js +19 -7
- package/lib/components/variables/VariableTag.js +48 -36
- package/lib/components/variables/types.d.ts +21 -0
- package/lib/flowContext.d.ts +12 -1
- package/lib/flowContext.js +47 -6
- package/lib/flowEngine.js +6 -0
- package/lib/flowI18n.js +3 -3
- package/lib/locale/en-US.json +2 -0
- package/lib/locale/index.d.ts +4 -0
- package/lib/locale/zh-CN.json +2 -0
- package/lib/resources/flowResource.js +1 -0
- package/lib/types.d.ts +3 -1
- package/lib/types.js +1 -0
- package/lib/utils/associationObjectVariable.d.ts +10 -0
- package/lib/utils/associationObjectVariable.js +10 -7
- package/lib/utils/dateVariable.d.ts +22 -0
- package/lib/utils/dateVariable.js +123 -16
- package/lib/utils/dirtyAwareApiClient.d.ts +1 -0
- package/lib/utils/dirtyAwareApiClient.js +280 -13
- package/lib/utils/index.d.ts +3 -3
- package/lib/utils/index.js +8 -0
- package/lib/utils/loadedPageCache.d.ts +1 -0
- package/lib/utils/loadedPageCache.js +6 -0
- package/lib/utils/params-resolvers.d.ts +3 -0
- package/lib/utils/params-resolvers.js +10 -0
- package/lib/utils/variablesParams.js +5 -0
- package/lib/views/createViewMeta.d.ts +1 -0
- package/lib/views/createViewMeta.js +53 -22
- package/package.json +4 -4
- package/src/__tests__/createViewMeta.popup.test.ts +84 -1
- package/src/__tests__/flowContext.test.ts +8 -0
- package/src/__tests__/flowI18n.test.ts +11 -0
- package/src/__tests__/objectVariable.test.ts +6 -1
- package/src/__tests__/runjsFormSubmit.test.ts +138 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +72 -6
- package/src/acl/Acl.tsx +36 -1
- package/src/acl/__tests__/Acl.test.tsx +70 -0
- package/src/components/FlowContextSelector.tsx +73 -12
- package/src/components/FormItem.tsx +12 -7
- package/src/components/MobilePopup.style.ts +12 -1
- package/src/components/MobilePopup.tsx +42 -10
- package/src/components/__tests__/FormItem.test.tsx +17 -2
- package/src/components/__tests__/MobilePopup.test.tsx +150 -0
- package/src/components/subModel/LazyDropdown.tsx +71 -38
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +85 -2
- package/src/components/subModel/__tests__/LazyDropdown.test.tsx +202 -0
- package/src/components/variables/VariableHybridInput.tsx +185 -14
- package/src/components/variables/VariableInput.tsx +32 -7
- package/src/components/variables/VariableTag.tsx +51 -37
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +95 -3
- package/src/components/variables/__tests__/VariableHybridInput.test.tsx +212 -0
- package/src/components/variables/__tests__/VariableInput.test.tsx +202 -6
- package/src/components/variables/__tests__/VariableTag.test.tsx +80 -0
- package/src/components/variables/types.ts +21 -0
- package/src/flowContext.ts +79 -6
- package/src/flowEngine.ts +6 -0
- package/src/flowI18n.ts +8 -3
- package/src/locale/__tests__/index.test.ts +21 -0
- package/src/locale/en-US.json +2 -0
- package/src/locale/zh-CN.json +2 -0
- package/src/resources/__tests__/flowResource.test.ts +3 -0
- package/src/resources/flowResource.ts +1 -0
- package/src/types.ts +2 -0
- package/src/utils/__tests__/dateVariable.test.ts +57 -4
- package/src/utils/__tests__/dirtyAwareApiClient.test.ts +321 -0
- package/src/utils/__tests__/variablesParams.test.ts +28 -1
- package/src/utils/associationObjectVariable.ts +9 -6
- package/src/utils/dateVariable.ts +145 -18
- package/src/utils/dirtyAwareApiClient.ts +348 -13
- package/src/utils/index.ts +17 -2
- package/src/utils/loadedPageCache.ts +7 -0
- package/src/utils/params-resolvers.ts +12 -0
- package/src/utils/variablesParams.ts +10 -0
- package/src/views/createViewMeta.ts +52 -18
|
@@ -27,12 +27,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var dirtyAwareApiClient_exports = {};
|
|
29
29
|
__export(dirtyAwareApiClient_exports, {
|
|
30
|
+
PREPARE_CONTEXT_RESOURCE_ACTION_PARAMS: () => PREPARE_CONTEXT_RESOURCE_ACTION_PARAMS,
|
|
30
31
|
SKIP_DATA_SOURCE_DIRTY: () => SKIP_DATA_SOURCE_DIRTY,
|
|
31
32
|
getDirtyAwareApiClient: () => getDirtyAwareApiClient
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(dirtyAwareApiClient_exports);
|
|
35
|
+
var import_sdk = require("@nocobase/sdk");
|
|
34
36
|
var import_dataSourceDirty = require("./dataSourceDirty");
|
|
35
37
|
const SKIP_DATA_SOURCE_DIRTY = "__nocobaseSkipDataSourceDirty";
|
|
38
|
+
const DIRTY_DISPATCH_TOKEN = Symbol("nocobaseDirtyDispatchToken");
|
|
39
|
+
const PREPARE_CONTEXT_RESOURCE_ACTION_PARAMS = Symbol("prepareContextResourceActionParams");
|
|
36
40
|
const dirtyAwareApiClientCache = /* @__PURE__ */ new WeakMap();
|
|
37
41
|
const dirtyAwareApiClientProxies = /* @__PURE__ */ new WeakSet();
|
|
38
42
|
const MUTATING_RESOURCE_ACTIONS = [
|
|
@@ -275,6 +279,7 @@ function resolveDirtyResourceActionFromResource(resourceName, resourceOf, action
|
|
|
275
279
|
}
|
|
276
280
|
return {
|
|
277
281
|
resourceName: normalizedResourceName,
|
|
282
|
+
resourceOf,
|
|
278
283
|
actionName: normalizedActionName
|
|
279
284
|
};
|
|
280
285
|
}
|
|
@@ -288,6 +293,43 @@ function resolveDirtyResourceAction(options, context) {
|
|
|
288
293
|
return parseDirtyResourceActionFromUrl(options == null ? void 0 : options.url, context);
|
|
289
294
|
}
|
|
290
295
|
__name(resolveDirtyResourceAction, "resolveDirtyResourceAction");
|
|
296
|
+
function getDirtyResourceActionDispatchKey(dirtyResourceAction, headers) {
|
|
297
|
+
if (!dirtyResourceAction) {
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
return JSON.stringify([
|
|
301
|
+
dirtyResourceAction.dataSourceKey || (0, import_dataSourceDirty.getDataSourceKeyFromHeaders)(headers),
|
|
302
|
+
dirtyResourceAction.resourceName,
|
|
303
|
+
dirtyResourceAction.actionName
|
|
304
|
+
]);
|
|
305
|
+
}
|
|
306
|
+
__name(getDirtyResourceActionDispatchKey, "getDirtyResourceActionDispatchKey");
|
|
307
|
+
function getRequestDispatchKey(options, context) {
|
|
308
|
+
return getDirtyResourceActionDispatchKey(resolveDirtyResourceAction(options, context), options.headers);
|
|
309
|
+
}
|
|
310
|
+
__name(getRequestDispatchKey, "getRequestDispatchKey");
|
|
311
|
+
function getResourceDispatchKey(name, of, headers) {
|
|
312
|
+
const resourceName = String(name ?? "").trim();
|
|
313
|
+
if (!resourceName) {
|
|
314
|
+
return void 0;
|
|
315
|
+
}
|
|
316
|
+
return JSON.stringify([resourceName, String(of ?? ""), (0, import_dataSourceDirty.getDataSourceKeyFromHeaders)(headers)]);
|
|
317
|
+
}
|
|
318
|
+
__name(getResourceDispatchKey, "getResourceDispatchKey");
|
|
319
|
+
function getMatchingRequestToken(token, requestKey) {
|
|
320
|
+
if (!token || !requestKey || token.requestKey && token.requestKey !== requestKey) {
|
|
321
|
+
return void 0;
|
|
322
|
+
}
|
|
323
|
+
return token;
|
|
324
|
+
}
|
|
325
|
+
__name(getMatchingRequestToken, "getMatchingRequestToken");
|
|
326
|
+
function getMatchingResourceToken(token, resourceKey) {
|
|
327
|
+
if (!token || !resourceKey || token.resourceKey && token.resourceKey !== resourceKey) {
|
|
328
|
+
return void 0;
|
|
329
|
+
}
|
|
330
|
+
return token;
|
|
331
|
+
}
|
|
332
|
+
__name(getMatchingResourceToken, "getMatchingResourceToken");
|
|
291
333
|
function markResourceActionDataSourceDirty(context, dirtyResourceAction, headers) {
|
|
292
334
|
(0, import_dataSourceDirty.markDataSourceDirty)({
|
|
293
335
|
engine: context.engine,
|
|
@@ -297,7 +339,19 @@ function markResourceActionDataSourceDirty(context, dirtyResourceAction, headers
|
|
|
297
339
|
});
|
|
298
340
|
}
|
|
299
341
|
__name(markResourceActionDataSourceDirty, "markResourceActionDataSourceDirty");
|
|
300
|
-
function
|
|
342
|
+
function markResourceActionDataSourceDirtyOnce(token, context, dirtyResourceAction, headers) {
|
|
343
|
+
if (token.skip || token.marked || !dirtyResourceAction || !isMutatingResourceAction(dirtyResourceAction.actionName)) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
token.marked = true;
|
|
347
|
+
markResourceActionDataSourceDirty(context, dirtyResourceAction, headers);
|
|
348
|
+
}
|
|
349
|
+
__name(markResourceActionDataSourceDirtyOnce, "markResourceActionDataSourceDirtyOnce");
|
|
350
|
+
function isObjectRecord(value) {
|
|
351
|
+
return !!value && typeof value === "object";
|
|
352
|
+
}
|
|
353
|
+
__name(isObjectRecord, "isObjectRecord");
|
|
354
|
+
function createDirtyAwareResource(context, resource, resourceName, resourceOf, headers, requestTokenStack, parentToken) {
|
|
301
355
|
return new Proxy(resource, {
|
|
302
356
|
get(target, prop, receiver) {
|
|
303
357
|
const original = Reflect.get(target, prop, receiver);
|
|
@@ -306,10 +360,47 @@ function createDirtyAwareResource(context, resource, resourceName, resourceOf, h
|
|
|
306
360
|
}
|
|
307
361
|
const action = original;
|
|
308
362
|
return async (...args) => {
|
|
309
|
-
const
|
|
363
|
+
const actionOptions = isObjectRecord(args[1]) ? args[1] : void 0;
|
|
310
364
|
const dirtyResourceAction = resolveDirtyResourceActionFromResource(resourceName, resourceOf, prop, context);
|
|
311
|
-
|
|
312
|
-
|
|
365
|
+
const prepareParams = context[PREPARE_CONTEXT_RESOURCE_ACTION_PARAMS];
|
|
366
|
+
const actionParams = dirtyResourceAction && typeof prepareParams === "function" ? prepareParams.call(
|
|
367
|
+
context,
|
|
368
|
+
{
|
|
369
|
+
...dirtyResourceAction,
|
|
370
|
+
dataSourceKey: dirtyResourceAction.dataSourceKey || (0, import_dataSourceDirty.getDataSourceKeyFromHeaders)(headers)
|
|
371
|
+
},
|
|
372
|
+
args[0]
|
|
373
|
+
) : args[0];
|
|
374
|
+
const requestKey = getDirtyResourceActionDispatchKey(dirtyResourceAction, headers);
|
|
375
|
+
const resourceKey = getResourceDispatchKey(resourceName, resourceOf, headers);
|
|
376
|
+
const inheritedToken = getMatchingRequestToken(
|
|
377
|
+
actionOptions == null ? void 0 : actionOptions[DIRTY_DISPATCH_TOKEN],
|
|
378
|
+
requestKey
|
|
379
|
+
) || getMatchingRequestToken(parentToken, requestKey);
|
|
380
|
+
const token = inheritedToken || { marked: false, skip: false };
|
|
381
|
+
const ownsToken = !inheritedToken;
|
|
382
|
+
token.requestKey ||= requestKey;
|
|
383
|
+
token.resourceKey ||= resourceKey;
|
|
384
|
+
if (actionOptions == null ? void 0 : actionOptions[SKIP_DATA_SOURCE_DIRTY]) {
|
|
385
|
+
token.skip = true;
|
|
386
|
+
}
|
|
387
|
+
const forwardedArgs = actionOptions || args[1] == null ? [
|
|
388
|
+
actionParams,
|
|
389
|
+
{
|
|
390
|
+
...actionOptions,
|
|
391
|
+
[DIRTY_DISPATCH_TOKEN]: token
|
|
392
|
+
}
|
|
393
|
+
] : [actionParams, args[1]];
|
|
394
|
+
let actionResult;
|
|
395
|
+
requestTokenStack.push({ key: requestKey, token });
|
|
396
|
+
try {
|
|
397
|
+
actionResult = Reflect.apply(action, receiver, forwardedArgs);
|
|
398
|
+
} finally {
|
|
399
|
+
requestTokenStack.pop();
|
|
400
|
+
}
|
|
401
|
+
const result = await actionResult;
|
|
402
|
+
if (ownsToken) {
|
|
403
|
+
markResourceActionDataSourceDirtyOnce(token, context, dirtyResourceAction, headers);
|
|
313
404
|
}
|
|
314
405
|
return result;
|
|
315
406
|
};
|
|
@@ -318,31 +409,206 @@ function createDirtyAwareResource(context, resource, resourceName, resourceOf, h
|
|
|
318
409
|
}
|
|
319
410
|
__name(createDirtyAwareResource, "createDirtyAwareResource");
|
|
320
411
|
function createDirtyAwareApiClient(api, context) {
|
|
412
|
+
const baseResource = api.resource;
|
|
413
|
+
const baseRequest = api.request;
|
|
414
|
+
const shouldUseResourceDispatchReceiver = baseResource === import_sdk.APIClient.prototype.resource;
|
|
415
|
+
const shouldUseRequestDispatchReceiver = baseRequest === import_sdk.APIClient.prototype.request;
|
|
416
|
+
const resourceTokenStack = [];
|
|
417
|
+
const requestTokenStack = [];
|
|
418
|
+
let hasResourceOverride = false;
|
|
419
|
+
let resourceOverride;
|
|
420
|
+
let hasRequestOverride = false;
|
|
421
|
+
let requestOverride;
|
|
422
|
+
const getCurrentResource = /* @__PURE__ */ __name(() => hasResourceOverride ? resourceOverride : resource, "getCurrentResource");
|
|
423
|
+
const getCurrentRequest = /* @__PURE__ */ __name(() => hasRequestOverride ? requestOverride : request, "getCurrentRequest");
|
|
424
|
+
const dispatchResource = /* @__PURE__ */ __name((token, args) => {
|
|
425
|
+
const resourceKey = getResourceDispatchKey(args[0], args[1], args[2]);
|
|
426
|
+
const activeToken = getMatchingResourceToken(token, resourceKey);
|
|
427
|
+
const shouldWrapActions = !!activeToken && hasResourceOverride;
|
|
428
|
+
if (activeToken) {
|
|
429
|
+
activeToken.resourceKey ||= resourceKey;
|
|
430
|
+
resourceTokenStack.push({ key: resourceKey, token: activeToken });
|
|
431
|
+
}
|
|
432
|
+
try {
|
|
433
|
+
const resourceInstance = Reflect.apply(getCurrentResource(), proxy, args);
|
|
434
|
+
if (!shouldWrapActions || !activeToken) {
|
|
435
|
+
return resourceInstance;
|
|
436
|
+
}
|
|
437
|
+
return new Proxy(resourceInstance, {
|
|
438
|
+
get(target, prop, receiver) {
|
|
439
|
+
const original = Reflect.get(target, prop, receiver);
|
|
440
|
+
if (typeof prop !== "string" || typeof original !== "function" || !isMutatingResourceAction(prop)) {
|
|
441
|
+
return original;
|
|
442
|
+
}
|
|
443
|
+
const action = original;
|
|
444
|
+
return (...actionArgs) => {
|
|
445
|
+
const actionOptions = isObjectRecord(actionArgs[1]) ? actionArgs[1] : void 0;
|
|
446
|
+
const forwardedArgs = actionOptions || actionArgs[1] == null ? [
|
|
447
|
+
actionArgs[0],
|
|
448
|
+
{
|
|
449
|
+
...actionOptions,
|
|
450
|
+
[DIRTY_DISPATCH_TOKEN]: activeToken
|
|
451
|
+
}
|
|
452
|
+
] : actionArgs;
|
|
453
|
+
resourceTokenStack.push({ key: resourceKey, token: activeToken });
|
|
454
|
+
requestTokenStack.push({ key: activeToken.requestKey, token: activeToken });
|
|
455
|
+
try {
|
|
456
|
+
return Reflect.apply(action, receiver, forwardedArgs);
|
|
457
|
+
} finally {
|
|
458
|
+
requestTokenStack.pop();
|
|
459
|
+
resourceTokenStack.pop();
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
} finally {
|
|
465
|
+
if (activeToken) {
|
|
466
|
+
resourceTokenStack.pop();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}, "dispatchResource");
|
|
470
|
+
const createDispatchReceiver = /* @__PURE__ */ __name((token) => {
|
|
471
|
+
const receiver = Object.create(api);
|
|
472
|
+
Object.defineProperties(receiver, {
|
|
473
|
+
request: {
|
|
474
|
+
configurable: true,
|
|
475
|
+
value: /* @__PURE__ */ __name((config) => {
|
|
476
|
+
const options = config;
|
|
477
|
+
const requestKey = getRequestDispatchKey(options, context);
|
|
478
|
+
const stackFrame = requestTokenStack.at(-1);
|
|
479
|
+
const activeToken = getMatchingRequestToken(options == null ? void 0 : options[DIRTY_DISPATCH_TOKEN], requestKey) || (requestKey && (stackFrame == null ? void 0 : stackFrame.key) === requestKey ? stackFrame.token : void 0) || getMatchingRequestToken(token, requestKey);
|
|
480
|
+
const { [DIRTY_DISPATCH_TOKEN]: _dirtyDispatchToken, ...cleanOptions } = options;
|
|
481
|
+
const configWithToken = activeToken ? { ...cleanOptions, [DIRTY_DISPATCH_TOKEN]: activeToken } : cleanOptions;
|
|
482
|
+
if (activeToken) {
|
|
483
|
+
activeToken.requestKey ||= requestKey;
|
|
484
|
+
requestTokenStack.push({ key: requestKey, token: activeToken });
|
|
485
|
+
}
|
|
486
|
+
try {
|
|
487
|
+
return Reflect.apply(getCurrentRequest(), proxy, [configWithToken]);
|
|
488
|
+
} finally {
|
|
489
|
+
if (activeToken) {
|
|
490
|
+
requestTokenStack.pop();
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}, "value")
|
|
494
|
+
},
|
|
495
|
+
resource: {
|
|
496
|
+
configurable: true,
|
|
497
|
+
value: /* @__PURE__ */ __name((...args) => {
|
|
498
|
+
const resourceKey = getResourceDispatchKey(args[0], args[1], args[2]);
|
|
499
|
+
const stackFrame = resourceTokenStack.at(-1);
|
|
500
|
+
const activeToken = getMatchingResourceToken(token, resourceKey) || (resourceKey && (stackFrame == null ? void 0 : stackFrame.key) === resourceKey ? stackFrame.token : void 0);
|
|
501
|
+
return dispatchResource(activeToken, args);
|
|
502
|
+
}, "value")
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
return receiver;
|
|
506
|
+
}, "createDispatchReceiver");
|
|
321
507
|
const resource = /* @__PURE__ */ __name((name, of, headers, cancel) => {
|
|
322
|
-
const
|
|
323
|
-
|
|
508
|
+
const resourceKey = getResourceDispatchKey(name, of, headers);
|
|
509
|
+
const stackFrame = resourceTokenStack.at(-1);
|
|
510
|
+
const parentToken = resourceKey && (stackFrame == null ? void 0 : stackFrame.key) === resourceKey ? stackFrame.token : void 0;
|
|
511
|
+
const receiver = createDispatchReceiver(parentToken);
|
|
512
|
+
const resourceInstance = Reflect.apply(baseResource, shouldUseResourceDispatchReceiver ? receiver : api, [
|
|
513
|
+
name,
|
|
514
|
+
of,
|
|
515
|
+
headers,
|
|
516
|
+
cancel
|
|
517
|
+
]);
|
|
518
|
+
return createDirtyAwareResource(context, resourceInstance, name, of, headers, requestTokenStack, parentToken);
|
|
324
519
|
}, "resource");
|
|
325
520
|
const request = /* @__PURE__ */ __name((config) => {
|
|
326
521
|
const options = config;
|
|
522
|
+
const requestKey = getRequestDispatchKey(options, context);
|
|
523
|
+
const stackFrame = requestTokenStack.at(-1);
|
|
524
|
+
const inheritedToken = getMatchingRequestToken(options == null ? void 0 : options[DIRTY_DISPATCH_TOKEN], requestKey) || (requestKey && (stackFrame == null ? void 0 : stackFrame.key) === requestKey ? stackFrame.token : void 0);
|
|
525
|
+
const token = inheritedToken || { marked: false, skip: false };
|
|
526
|
+
const ownsToken = !inheritedToken;
|
|
527
|
+
token.requestKey ||= requestKey;
|
|
528
|
+
if (typeof options.resource === "string") {
|
|
529
|
+
token.resourceKey ||= getResourceDispatchKey(options.resource, options.resourceOf, options.headers);
|
|
530
|
+
}
|
|
327
531
|
const skipDataSourceDirty = options == null ? void 0 : options[SKIP_DATA_SOURCE_DIRTY];
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
532
|
+
if (skipDataSourceDirty) {
|
|
533
|
+
token.skip = true;
|
|
534
|
+
}
|
|
535
|
+
const dirtyResourceAction = resolveDirtyResourceAction(options, context);
|
|
536
|
+
const {
|
|
537
|
+
[DIRTY_DISPATCH_TOKEN]: _dirtyDispatchToken,
|
|
538
|
+
[SKIP_DATA_SOURCE_DIRTY]: _skipDataSourceDirty,
|
|
539
|
+
...cleanConfig
|
|
540
|
+
} = options;
|
|
541
|
+
const receiver = createDispatchReceiver(token);
|
|
542
|
+
return Reflect.apply(baseRequest, shouldUseRequestDispatchReceiver ? receiver : api, [cleanConfig]).then((result) => {
|
|
543
|
+
if (ownsToken) {
|
|
544
|
+
markResourceActionDataSourceDirtyOnce(token, context, dirtyResourceAction, options.headers);
|
|
333
545
|
}
|
|
334
546
|
return result;
|
|
335
547
|
});
|
|
336
548
|
}, "request");
|
|
549
|
+
const isLockedOwnProperty = /* @__PURE__ */ __name((target, prop) => {
|
|
550
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
551
|
+
return !!descriptor && !descriptor.configurable;
|
|
552
|
+
}, "isLockedOwnProperty");
|
|
337
553
|
const proxy = new Proxy(api, {
|
|
338
554
|
get(target, prop, receiver) {
|
|
339
555
|
if (prop === "resource") {
|
|
340
|
-
|
|
556
|
+
if (isLockedOwnProperty(target, prop)) {
|
|
557
|
+
return Reflect.get(target, prop, receiver);
|
|
558
|
+
}
|
|
559
|
+
return hasResourceOverride ? resourceOverride : resource;
|
|
341
560
|
}
|
|
342
561
|
if (prop === "request") {
|
|
343
|
-
|
|
562
|
+
if (isLockedOwnProperty(target, prop)) {
|
|
563
|
+
return Reflect.get(target, prop, receiver);
|
|
564
|
+
}
|
|
565
|
+
return hasRequestOverride ? requestOverride : request;
|
|
344
566
|
}
|
|
345
567
|
return Reflect.get(target, prop, receiver);
|
|
568
|
+
},
|
|
569
|
+
set(target, prop, value, receiver) {
|
|
570
|
+
if (prop === "resource") {
|
|
571
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
572
|
+
if (descriptor && (!descriptor.configurable || !Reflect.isExtensible(target))) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
hasResourceOverride = true;
|
|
576
|
+
resourceOverride = value;
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
if (prop === "request") {
|
|
580
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
581
|
+
if (descriptor && (!descriptor.configurable || !Reflect.isExtensible(target))) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
hasRequestOverride = true;
|
|
585
|
+
requestOverride = value;
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
588
|
+
return Reflect.set(target, prop, value, receiver);
|
|
589
|
+
},
|
|
590
|
+
deleteProperty(target, prop) {
|
|
591
|
+
if (prop !== "resource" && prop !== "request") {
|
|
592
|
+
return Reflect.deleteProperty(target, prop);
|
|
593
|
+
}
|
|
594
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
595
|
+
if (descriptor && (!descriptor.configurable || !Reflect.isExtensible(target))) {
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
if (prop === "resource") {
|
|
599
|
+
hasResourceOverride = false;
|
|
600
|
+
resourceOverride = void 0;
|
|
601
|
+
} else {
|
|
602
|
+
hasRequestOverride = false;
|
|
603
|
+
requestOverride = void 0;
|
|
604
|
+
}
|
|
605
|
+
return true;
|
|
606
|
+
},
|
|
607
|
+
defineProperty(target, prop, descriptor) {
|
|
608
|
+
if (prop === "resource" || prop === "request") {
|
|
609
|
+
return false;
|
|
610
|
+
}
|
|
611
|
+
return Reflect.defineProperty(target, prop, descriptor);
|
|
346
612
|
}
|
|
347
613
|
});
|
|
348
614
|
dirtyAwareApiClientProxies.add(proxy);
|
|
@@ -373,6 +639,7 @@ function getDirtyAwareApiClient(value, context) {
|
|
|
373
639
|
__name(getDirtyAwareApiClient, "getDirtyAwareApiClient");
|
|
374
640
|
// Annotate the CommonJS export names for ESM import in node:
|
|
375
641
|
0 && (module.exports = {
|
|
642
|
+
PREPARE_CONTEXT_RESOURCE_ACTION_PARAMS,
|
|
376
643
|
SKIP_DATA_SOURCE_DIRTY,
|
|
377
644
|
getDirtyAwareApiClient
|
|
378
645
|
});
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -11,17 +11,17 @@ export { escapeT, getT, tExpr } from './translation';
|
|
|
11
11
|
export { FlowCancelSaveException, FlowExitAllException, FlowExitException } from './exceptions';
|
|
12
12
|
export { defineAction } from './flow-definitions';
|
|
13
13
|
export { isInheritedFrom } from './inheritance';
|
|
14
|
-
export { resolveCreateModelOptions, resolveDefaultParams, resolveExpressions } from './params-resolvers';
|
|
14
|
+
export { buildFlowModelResolveDescriptor, resolveCreateModelOptions, resolveDefaultParams, resolveExpressions, } from './params-resolvers';
|
|
15
15
|
export { compileUiSchema, resolveStepUiSchema, resolveStepDisabledInSettings, resolveUiMode, shouldHideEventInSettings, shouldHideStepInSettings, } from './schema-utils';
|
|
16
16
|
export { setupRuntimeContextSteps } from './setupRuntimeContextSteps';
|
|
17
17
|
export { createCollectionContextMeta } from './createCollectionContextMeta';
|
|
18
|
-
export { createAssociationAwareObjectMetaFactory, createAssociationSubpathResolver } from './associationObjectVariable';
|
|
18
|
+
export { createAssociationAwareObjectMetaFactory, createAssociationSubpathResolver, getAssociationFilterByTk, } from './associationObjectVariable';
|
|
19
19
|
export { buildRecordMeta, collectContextParamsForTemplate, createCurrentRecordMetaFactory, createRecordResolveOnServerWithLocal, createRecordMetaFactory, extractUsedVariableNames, extractUsedVariablePaths, inferRecordRef, type RecordParamsBuilder, } from './variablesParams';
|
|
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
23
|
export { createOpenViewRouteState, decodeOpenViewRouteState, encodeOpenViewRouteState, isOpenViewRouteStateToken, RUNJS_OPEN_VIEW_ROUTE_STATE, type OpenViewRouteMode, type OpenViewRouteSize, type OpenViewRouteState, } from './openViewRouteState';
|
|
24
|
-
export { decodeBase64Url, encodeBase64Url, isCompleteCtxDatePath, isCtxDatePathPrefix, isCtxDateExpression, parseCtxDateExpression, resolveCtxDatePath, serializeCtxDateValue, } from './dateVariable';
|
|
24
|
+
export { decodeBase64Url, encodeBase64Url, isCompleteCtxDatePath, isCtxDatePathPrefix, isCtxDateExpression, parseCtxDateExpression, parseCtxDateExpressionConfig, resolveCtxDatePath, serializeCtxDateExpressionConfig, serializeCtxDateValue, type CtxDateExpressionConfig, type CtxDatePreset, type CtxDateRelativeDirection, type CtxDateRelativeUnit, } from './dateVariable';
|
|
25
25
|
export { isRunJSValue, normalizeRunJSValue, extractUsedVariablePathsFromRunJS, type RunJSValue } from './runjsValue';
|
|
26
26
|
export { resolveRunJSObjectValues } from './resolveRunJSObjectValues';
|
|
27
27
|
export { prepareRunJsCode, preprocessRunJsTemplates } from './runjsTemplateCompat';
|
package/lib/utils/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(utils_exports, {
|
|
|
34
34
|
FlowExitException: () => import_exceptions.FlowExitException,
|
|
35
35
|
MENU_KEYS: () => import_constants.MENU_KEYS,
|
|
36
36
|
RUNJS_OPEN_VIEW_ROUTE_STATE: () => import_openViewRouteState.RUNJS_OPEN_VIEW_ROUTE_STATE,
|
|
37
|
+
buildFlowModelResolveDescriptor: () => import_params_resolvers.buildFlowModelResolveDescriptor,
|
|
37
38
|
buildRecordMeta: () => import_variablesParams.buildRecordMeta,
|
|
38
39
|
clearAutoFlowError: () => import_autoFlowError.clearAutoFlowError,
|
|
39
40
|
collectContextParamsForTemplate: () => import_variablesParams.collectContextParamsForTemplate,
|
|
@@ -57,6 +58,7 @@ __export(utils_exports, {
|
|
|
57
58
|
extractUsedVariablePaths: () => import_variablesParams.extractUsedVariablePaths,
|
|
58
59
|
extractUsedVariablePathsFromRunJS: () => import_runjsValue.extractUsedVariablePathsFromRunJS,
|
|
59
60
|
formatPathToVariable: () => import_context.formatPathToVariable,
|
|
61
|
+
getAssociationFilterByTk: () => import_associationObjectVariable.getAssociationFilterByTk,
|
|
60
62
|
getAutoFlowError: () => import_autoFlowError.getAutoFlowError,
|
|
61
63
|
getT: () => import_translation.getT,
|
|
62
64
|
inferRecordRef: () => import_variablesParams.inferRecordRef,
|
|
@@ -71,6 +73,7 @@ __export(utils_exports, {
|
|
|
71
73
|
isVariableExpression: () => import_context.isVariableExpression,
|
|
72
74
|
normalizeRunJSValue: () => import_runjsValue.normalizeRunJSValue,
|
|
73
75
|
parseCtxDateExpression: () => import_dateVariable.parseCtxDateExpression,
|
|
76
|
+
parseCtxDateExpressionConfig: () => import_dateVariable.parseCtxDateExpressionConfig,
|
|
74
77
|
parsePathnameToViewParams: () => import_parsePathnameToViewParams.parsePathnameToViewParams,
|
|
75
78
|
prepareRunJsCode: () => import_runjsTemplateCompat.prepareRunJsCode,
|
|
76
79
|
preprocessRunJsTemplates: () => import_runjsTemplateCompat.preprocessRunJsTemplates,
|
|
@@ -85,6 +88,7 @@ __export(utils_exports, {
|
|
|
85
88
|
resolveStepDisabledInSettings: () => import_schema_utils.resolveStepDisabledInSettings,
|
|
86
89
|
resolveStepUiSchema: () => import_schema_utils.resolveStepUiSchema,
|
|
87
90
|
resolveUiMode: () => import_schema_utils.resolveUiMode,
|
|
91
|
+
serializeCtxDateExpressionConfig: () => import_dateVariable.serializeCtxDateExpressionConfig,
|
|
88
92
|
serializeCtxDateValue: () => import_dateVariable.serializeCtxDateValue,
|
|
89
93
|
setAutoFlowError: () => import_autoFlowError.setAutoFlowError,
|
|
90
94
|
setupRuntimeContextSteps: () => import_setupRuntimeContextSteps.setupRuntimeContextSteps,
|
|
@@ -127,6 +131,7 @@ var import_randomId = require("./randomId");
|
|
|
127
131
|
FlowExitException,
|
|
128
132
|
MENU_KEYS,
|
|
129
133
|
RUNJS_OPEN_VIEW_ROUTE_STATE,
|
|
134
|
+
buildFlowModelResolveDescriptor,
|
|
130
135
|
buildRecordMeta,
|
|
131
136
|
clearAutoFlowError,
|
|
132
137
|
collectContextParamsForTemplate,
|
|
@@ -150,6 +155,7 @@ var import_randomId = require("./randomId");
|
|
|
150
155
|
extractUsedVariablePaths,
|
|
151
156
|
extractUsedVariablePathsFromRunJS,
|
|
152
157
|
formatPathToVariable,
|
|
158
|
+
getAssociationFilterByTk,
|
|
153
159
|
getAutoFlowError,
|
|
154
160
|
getT,
|
|
155
161
|
inferRecordRef,
|
|
@@ -164,6 +170,7 @@ var import_randomId = require("./randomId");
|
|
|
164
170
|
isVariableExpression,
|
|
165
171
|
normalizeRunJSValue,
|
|
166
172
|
parseCtxDateExpression,
|
|
173
|
+
parseCtxDateExpressionConfig,
|
|
167
174
|
parsePathnameToViewParams,
|
|
168
175
|
prepareRunJsCode,
|
|
169
176
|
preprocessRunJsTemplates,
|
|
@@ -178,6 +185,7 @@ var import_randomId = require("./randomId");
|
|
|
178
185
|
resolveStepDisabledInSettings,
|
|
179
186
|
resolveStepUiSchema,
|
|
180
187
|
resolveUiMode,
|
|
188
|
+
serializeCtxDateExpressionConfig,
|
|
181
189
|
serializeCtxDateValue,
|
|
182
190
|
setAutoFlowError,
|
|
183
191
|
setupRuntimeContextSteps,
|
|
@@ -17,6 +17,7 @@ type DirtyKeyOptions = {
|
|
|
17
17
|
export declare const createLoadedPageCache: () => {
|
|
18
18
|
getDirtyKeyForModel(model?: FlowModel | null, options?: DirtyKeyOptions): string | undefined;
|
|
19
19
|
markDirty(key?: string): void;
|
|
20
|
+
markDirtyForOptions(options?: LoadedPageOptions): void;
|
|
20
21
|
shouldBypass(options?: LoadedPageOptions, isFlowSettingsEnabled?: () => boolean): boolean;
|
|
21
22
|
clear(options?: LoadedPageOptions): void;
|
|
22
23
|
mountModelToParent: <T extends FlowModel<import("..").DefaultStructure> = FlowModel<import("..").DefaultStructure>>(model: T, forceReplace?: boolean) => T;
|
|
@@ -113,6 +113,12 @@ const createLoadedPageCache = /* @__PURE__ */ __name(() => {
|
|
|
113
113
|
dirtyKeys.add(key);
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
|
+
markDirtyForOptions(options) {
|
|
117
|
+
const key = getLoadedPageKey(options);
|
|
118
|
+
if (key) {
|
|
119
|
+
dirtyKeys.add(key);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
116
122
|
shouldBypass(options, isFlowSettingsEnabled) {
|
|
117
123
|
const key = getLoadedPageKey(options);
|
|
118
124
|
if (!key || !dirtyKeys.has(key)) {
|
|
@@ -27,10 +27,13 @@ export type JSONValue = string | {
|
|
|
27
27
|
[key: string]: JSONValue;
|
|
28
28
|
} | JSONValue[];
|
|
29
29
|
type BatchPayload = {
|
|
30
|
+
contractRd?: string;
|
|
31
|
+
rd?: string;
|
|
30
32
|
template: JSONValue;
|
|
31
33
|
contextParams?: ServerContextParams | undefined;
|
|
32
34
|
};
|
|
33
35
|
export declare function enqueueVariablesResolve(ctx: FlowRuntimeContext, payload: BatchPayload): Promise<unknown>;
|
|
36
|
+
export declare function buildFlowModelResolveDescriptor(ctx: Pick<FlowModelContext, 'api'>, flowModelUid?: string | number | null): any;
|
|
34
37
|
/**
|
|
35
38
|
* 解析参数中的 {{xxx}} 表达式,自动处理异步属性访问
|
|
36
39
|
*/
|
|
@@ -37,6 +37,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
var params_resolvers_exports = {};
|
|
39
39
|
__export(params_resolvers_exports, {
|
|
40
|
+
buildFlowModelResolveDescriptor: () => buildFlowModelResolveDescriptor,
|
|
40
41
|
enqueueVariablesResolve: () => enqueueVariablesResolve,
|
|
41
42
|
preprocessExpression: () => preprocessExpression,
|
|
42
43
|
resolveCreateModelOptions: () => resolveCreateModelOptions,
|
|
@@ -45,6 +46,7 @@ __export(params_resolvers_exports, {
|
|
|
45
46
|
});
|
|
46
47
|
module.exports = __toCommonJS(params_resolvers_exports);
|
|
47
48
|
var import_shared = require("@nocobase/shared");
|
|
49
|
+
var import_client = require("@nocobase/utils/client");
|
|
48
50
|
var import_lodash = __toESM(require("lodash"));
|
|
49
51
|
async function resolveDefaultParams(defaultParams, ctx) {
|
|
50
52
|
if (!defaultParams) {
|
|
@@ -144,6 +146,8 @@ function enqueueVariablesResolve(ctx, payload) {
|
|
|
144
146
|
try {
|
|
145
147
|
const batch = items.map((it) => ({
|
|
146
148
|
id: it.id,
|
|
149
|
+
contractRd: it.payload.contractRd,
|
|
150
|
+
rd: it.payload.rd,
|
|
147
151
|
template: it.payload.template,
|
|
148
152
|
contextParams: it.payload.contextParams || {}
|
|
149
153
|
}));
|
|
@@ -187,6 +191,11 @@ function enqueueVariablesResolve(ctx, payload) {
|
|
|
187
191
|
return p;
|
|
188
192
|
}
|
|
189
193
|
__name(enqueueVariablesResolve, "enqueueVariablesResolve");
|
|
194
|
+
function buildFlowModelResolveDescriptor(ctx, flowModelUid) {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
return (0, import_client.generateFlowModelRdFromToken)(flowModelUid, (_b = (_a = ctx == null ? void 0 : ctx.api) == null ? void 0 : _a.auth) == null ? void 0 : _b.token);
|
|
197
|
+
}
|
|
198
|
+
__name(buildFlowModelResolveDescriptor, "buildFlowModelResolveDescriptor");
|
|
190
199
|
async function resolveExpressions(params, ctx) {
|
|
191
200
|
const compile = /* @__PURE__ */ __name(async (source) => {
|
|
192
201
|
if (typeof source === "string" && /\{\{.*?\}\}/.test(source)) {
|
|
@@ -308,6 +317,7 @@ async function compileExpression(expression, ctx) {
|
|
|
308
317
|
__name(compileExpression, "compileExpression");
|
|
309
318
|
// Annotate the CommonJS export names for ESM import in node:
|
|
310
319
|
0 && (module.exports = {
|
|
320
|
+
buildFlowModelResolveDescriptor,
|
|
311
321
|
enqueueVariablesResolve,
|
|
312
322
|
preprocessExpression,
|
|
313
323
|
resolveCreateModelOptions,
|
|
@@ -210,6 +210,11 @@ async function collectContextParamsForTemplate(ctx, template) {
|
|
|
210
210
|
input[key] = built;
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
+
const viewPaths = usage.view || [];
|
|
214
|
+
if (!input.view && viewPaths.some((path) => path === "record" || path.startsWith("record.") || path.startsWith("record["))) {
|
|
215
|
+
const recordRef = inferViewRecordRef(ctx);
|
|
216
|
+
if (recordRef) input.view = { record: recordRef };
|
|
217
|
+
}
|
|
213
218
|
return (0, import_serverContextParams.buildServerContextParams)(ctx, input);
|
|
214
219
|
}
|
|
215
220
|
__name(collectContextParamsForTemplate, "collectContextParamsForTemplate");
|
|
@@ -28,6 +28,7 @@ interface PopupNodeResource {
|
|
|
28
28
|
interface PopupNode {
|
|
29
29
|
uid?: string;
|
|
30
30
|
resource: PopupNodeResource;
|
|
31
|
+
sourceRecord?: unknown;
|
|
31
32
|
parent?: PopupNode;
|
|
32
33
|
}
|
|
33
34
|
export declare function buildPopupRuntime(ctx: FlowContext, view: FlowView): Promise<PopupNode | undefined>;
|