@nocobase/flow-engine 2.2.0-beta.7 → 2.2.0-beta.8
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/components/MobilePopup.style.js +16 -5
- package/lib/flowContext.d.ts +1 -1
- package/lib/flowContext.js +22 -6
- package/lib/locale/en-US.json +1 -0
- package/lib/locale/index.d.ts +2 -0
- package/lib/locale/zh-CN.json +1 -0
- package/lib/resources/apiResource.js +2 -1
- package/lib/resources/baseRecordResource.js +6 -17
- package/lib/resources/multiRecordResource.js +13 -3
- package/lib/resources/singleRecordResource.js +7 -2
- package/lib/utils/dataSourceDirty.d.ts +20 -0
- package/lib/utils/dataSourceDirty.js +139 -0
- package/lib/utils/dirtyAwareApiClient.d.ts +11 -0
- package/lib/utils/dirtyAwareApiClient.js +378 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +11 -0
- package/lib/utils/openViewRouteState.d.ts +28 -0
- package/lib/utils/openViewRouteState.js +125 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +3 -0
- package/lib/utils/parsePathnameToViewParams.js +18 -1
- package/lib/views/ViewNavigation.js +5 -0
- package/package.json +4 -4
- package/src/__tests__/flowContext.test.ts +88 -0
- package/src/__tests__/flowEngine.dataSourceDirty.test.ts +51 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +15 -2
- package/src/components/MobilePopup.style.ts +22 -6
- package/src/components/__tests__/MobilePopup.style.test.tsx +103 -0
- package/src/flowContext.ts +32 -7
- package/src/locale/en-US.json +1 -0
- package/src/locale/zh-CN.json +1 -0
- package/src/resources/apiResource.ts +2 -1
- package/src/resources/baseRecordResource.ts +6 -23
- package/src/resources/multiRecordResource.ts +13 -3
- package/src/resources/singleRecordResource.ts +6 -1
- package/src/utils/__tests__/dirtyAwareApiClient.test.ts +392 -0
- package/src/utils/__tests__/openViewRouteState.test.ts +40 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +36 -0
- package/src/utils/dataSourceDirty.ts +126 -0
- package/src/utils/dirtyAwareApiClient.ts +430 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/openViewRouteState.ts +107 -0
- package/src/utils/parsePathnameToViewParams.ts +23 -1
- package/src/views/ViewNavigation.ts +6 -1
- package/src/views/__tests__/ViewNavigation.test.ts +15 -0
|
@@ -96,9 +96,17 @@ const genStyleHook = /* @__PURE__ */ __name((component, styleFn) => {
|
|
|
96
96
|
return [genCommonStyle(token, prefixCls), styleInterpolation];
|
|
97
97
|
}
|
|
98
98
|
);
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const wrapSSRDeps = [theme2, token, hashId, prefixCls, iconPrefixCls, rootPrefixCls, props];
|
|
100
|
+
const wrapSSRCacheRef = (0, import_react.useRef)();
|
|
101
|
+
const currentCache = wrapSSRCacheRef.current;
|
|
102
|
+
let memoizedWrapSSR = (currentCache == null ? void 0 : currentCache.wrapSSR) || wrapSSR;
|
|
103
|
+
if (!currentCache || wrapSSRDeps.some((dep, index) => dep !== currentCache.deps[index])) {
|
|
104
|
+
wrapSSRCacheRef.current = {
|
|
105
|
+
deps: wrapSSRDeps,
|
|
106
|
+
wrapSSR
|
|
107
|
+
};
|
|
108
|
+
memoizedWrapSSR = wrapSSR;
|
|
109
|
+
}
|
|
102
110
|
return {
|
|
103
111
|
wrapSSR: memoizedWrapSSR,
|
|
104
112
|
hashId,
|
|
@@ -112,7 +120,7 @@ const useMobileActionDrawerStyle = genStyleHook("nb-mobile-action-drawer", (toke
|
|
|
112
120
|
return {
|
|
113
121
|
[componentCls]: {
|
|
114
122
|
".nb-mobile-action-drawer-header": {
|
|
115
|
-
height: "var(--nb-mobile-page-header-height)",
|
|
123
|
+
height: "var(--nb-mobile-page-header-height, 46px)",
|
|
116
124
|
display: "flex",
|
|
117
125
|
alignItems: "center",
|
|
118
126
|
justifyContent: "space-between",
|
|
@@ -139,7 +147,10 @@ const useMobileActionDrawerStyle = genStyleHook("nb-mobile-action-drawer", (toke
|
|
|
139
147
|
".nb-mobile-action-drawer-body": {
|
|
140
148
|
borderTopLeftRadius: 8,
|
|
141
149
|
borderTopRightRadius: 8,
|
|
142
|
-
maxHeight: "calc(
|
|
150
|
+
maxHeight: "calc(100vh - var(--nb-mobile-page-header-height, 46px))",
|
|
151
|
+
"@supports (height: 100dvh)": {
|
|
152
|
+
maxHeight: "calc(100dvh - var(--nb-mobile-page-header-height, 46px))"
|
|
153
|
+
},
|
|
143
154
|
overflowY: "auto",
|
|
144
155
|
overflowX: "hidden",
|
|
145
156
|
backgroundColor: token.colorBgLayout,
|
package/lib/flowContext.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { ISchema } from '@formily/json-schema';
|
|
10
|
-
import { APIClient, RequestOptions } from '@nocobase/sdk';
|
|
10
|
+
import type { APIClient, RequestOptions } from '@nocobase/sdk';
|
|
11
11
|
import type { Router } from '@remix-run/router';
|
|
12
12
|
import { MessageInstance } from 'antd/es/message/interface';
|
|
13
13
|
import type { HookAPI } from 'antd/es/modal/useModal';
|
package/lib/flowContext.js
CHANGED
|
@@ -75,6 +75,7 @@ var import_utils = require("./utils");
|
|
|
75
75
|
var import_exceptions = require("./utils/exceptions");
|
|
76
76
|
var import_params_resolvers = require("./utils/params-resolvers");
|
|
77
77
|
var import_serverContextParams = require("./utils/serverContextParams");
|
|
78
|
+
var import_dirtyAwareApiClient = require("./utils/dirtyAwareApiClient");
|
|
78
79
|
var import_variablesParams = require("./utils/variablesParams");
|
|
79
80
|
var import_registry = require("./runjs-context/registry");
|
|
80
81
|
var import_createEphemeralContext = require("./utils/createEphemeralContext");
|
|
@@ -1899,15 +1900,16 @@ const _FlowContext = class _FlowContext {
|
|
|
1899
1900
|
const options = this._props[key];
|
|
1900
1901
|
if (!options) return void 0;
|
|
1901
1902
|
if ("value" in options) {
|
|
1902
|
-
return options.value;
|
|
1903
|
+
return key === "api" ? (0, import_dirtyAwareApiClient.getDirtyAwareApiClient)(options.value, currentContext) : options.value;
|
|
1903
1904
|
}
|
|
1904
1905
|
if (options.get) {
|
|
1905
1906
|
if (options.cache === false) {
|
|
1906
|
-
|
|
1907
|
+
const value = options.get(currentContext);
|
|
1908
|
+
return key === "api" ? (0, import_dirtyAwareApiClient.getDirtyAwareApiClient)(value, currentContext) : value;
|
|
1907
1909
|
}
|
|
1908
1910
|
const cacheKey = options.observable ? "_observableCache" : "_cache";
|
|
1909
1911
|
if (key in this[cacheKey]) {
|
|
1910
|
-
return this[cacheKey][key];
|
|
1912
|
+
return key === "api" ? (0, import_dirtyAwareApiClient.getDirtyAwareApiClient)(this[cacheKey][key], currentContext) : this[cacheKey][key];
|
|
1911
1913
|
}
|
|
1912
1914
|
if (this._pending[key]) return this._pending[key];
|
|
1913
1915
|
const result = options.get(this.createProxy());
|
|
@@ -1917,7 +1919,7 @@ const _FlowContext = class _FlowContext {
|
|
|
1917
1919
|
(v) => {
|
|
1918
1920
|
this[cacheKey][key] = v;
|
|
1919
1921
|
delete this._pending[key];
|
|
1920
|
-
return v;
|
|
1922
|
+
return key === "api" ? (0, import_dirtyAwareApiClient.getDirtyAwareApiClient)(v, currentContext) : v;
|
|
1921
1923
|
},
|
|
1922
1924
|
(err) => {
|
|
1923
1925
|
delete this._pending[key];
|
|
@@ -1927,7 +1929,7 @@ const _FlowContext = class _FlowContext {
|
|
|
1927
1929
|
return this._pending[key];
|
|
1928
1930
|
}
|
|
1929
1931
|
this[cacheKey][key] = result;
|
|
1930
|
-
return result;
|
|
1932
|
+
return key === "api" ? (0, import_dirtyAwareApiClient.getDirtyAwareApiClient)(result, currentContext) : result;
|
|
1931
1933
|
}
|
|
1932
1934
|
return void 0;
|
|
1933
1935
|
}
|
|
@@ -2251,7 +2253,7 @@ const _BaseFlowEngineContext = class _BaseFlowEngineContext extends FlowContext
|
|
|
2251
2253
|
this.defineMethod("getModel", (modelName, searchInPreviousEngines) => {
|
|
2252
2254
|
return this.engine.getModel(modelName, searchInPreviousEngines);
|
|
2253
2255
|
});
|
|
2254
|
-
this.defineMethod("request", (options)
|
|
2256
|
+
this.defineMethod("request", function(options) {
|
|
2255
2257
|
const app = this.app;
|
|
2256
2258
|
if (typeof (options == null ? void 0 : options.url) === "string" && shouldBypassApiClient(options.url, app)) {
|
|
2257
2259
|
return import_axios.default.request(options);
|
|
@@ -3510,6 +3512,20 @@ const _FlowRunJSContext = class _FlowRunJSContext extends FlowContext {
|
|
|
3510
3512
|
ReactDOMShim.__nbRunjsInternalShim = true;
|
|
3511
3513
|
this.defineProperty("ReactDOM", { value: ReactDOMShim });
|
|
3512
3514
|
(0, import_runjsLibs.setupRunJSLibs)(this);
|
|
3515
|
+
this.defineMethod("openView", async function(uid, options) {
|
|
3516
|
+
const delegateOpenView = delegate.openView;
|
|
3517
|
+
if (typeof delegateOpenView !== "function") {
|
|
3518
|
+
throw new Error("ctx.openView is not available in current context.");
|
|
3519
|
+
}
|
|
3520
|
+
const routeState = (0, import_utils.createOpenViewRouteState)(options);
|
|
3521
|
+
if (!routeState) {
|
|
3522
|
+
return delegateOpenView(uid, options);
|
|
3523
|
+
}
|
|
3524
|
+
return delegateOpenView(uid, {
|
|
3525
|
+
...options || {},
|
|
3526
|
+
[import_utils.RUNJS_OPEN_VIEW_ROUTE_STATE]: routeState
|
|
3527
|
+
});
|
|
3528
|
+
});
|
|
3513
3529
|
this.defineMethod(
|
|
3514
3530
|
"render",
|
|
3515
3531
|
function(vnode, container) {
|
package/lib/locale/en-US.json
CHANGED
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"Replace current block with template?": "Replace current block with template?",
|
|
57
57
|
"Replaced with template block": "Replaced with template block",
|
|
58
58
|
"Render failed": "Render failed",
|
|
59
|
+
"Response record": "Response record",
|
|
59
60
|
"Step configuration": "Step configuration",
|
|
60
61
|
"Step parameter configuration": "Step parameter configuration",
|
|
61
62
|
"Step with key {{stepKey}} not found": "Step with key {{stepKey}} not found",
|
package/lib/locale/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export declare const locales: {
|
|
|
65
65
|
"Replace current block with template?": string;
|
|
66
66
|
"Replaced with template block": string;
|
|
67
67
|
"Render failed": string;
|
|
68
|
+
"Response record": string;
|
|
68
69
|
"Step configuration": string;
|
|
69
70
|
"Step parameter configuration": string;
|
|
70
71
|
"Step with key {{stepKey}} not found": string;
|
|
@@ -150,6 +151,7 @@ export declare const locales: {
|
|
|
150
151
|
"Other blocks": string;
|
|
151
152
|
"Previous step": string;
|
|
152
153
|
"Render failed": string;
|
|
154
|
+
"Response record": string;
|
|
153
155
|
"Step configuration": string;
|
|
154
156
|
"Step parameter configuration": string;
|
|
155
157
|
"Step with key {{stepKey}} not found": string;
|
package/lib/locale/zh-CN.json
CHANGED
|
@@ -30,6 +30,7 @@ __export(apiResource_exports, {
|
|
|
30
30
|
APIResource: () => APIResource
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(apiResource_exports);
|
|
33
|
+
var import_dirtyAwareApiClient = require("../utils/dirtyAwareApiClient");
|
|
33
34
|
var import_flowResource = require("./flowResource");
|
|
34
35
|
const _APIResource = class _APIResource extends import_flowResource.FlowResource {
|
|
35
36
|
// 请求配置
|
|
@@ -49,7 +50,7 @@ const _APIResource = class _APIResource extends import_flowResource.FlowResource
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
setAPIClient(api) {
|
|
52
|
-
this.api = api;
|
|
53
|
+
this.api = (0, import_dirtyAwareApiClient.getDirtyAwareApiClient)(api, this.context);
|
|
53
54
|
return this;
|
|
54
55
|
}
|
|
55
56
|
getURL() {
|
|
@@ -44,7 +44,7 @@ var import_lodash = __toESM(require("lodash"));
|
|
|
44
44
|
var import_apiResource = require("./apiResource");
|
|
45
45
|
var import_filterItem = require("./filterItem");
|
|
46
46
|
var import_flowResource = require("./flowResource");
|
|
47
|
-
var
|
|
47
|
+
var import_dataSourceDirty = require("../utils/dataSourceDirty");
|
|
48
48
|
const _BaseRecordResource = class _BaseRecordResource extends import_apiResource.APIResource {
|
|
49
49
|
resourceName;
|
|
50
50
|
sourceId = null;
|
|
@@ -151,22 +151,11 @@ const _BaseRecordResource = class _BaseRecordResource extends import_apiResource
|
|
|
151
151
|
* Used to coordinate "refresh on active" across view stacks.
|
|
152
152
|
*/
|
|
153
153
|
markDataSourceDirty(resourceName) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!resName) return;
|
|
160
|
-
const affectedResourceNames = /* @__PURE__ */ new Set([String(resName)]);
|
|
161
|
-
if (typeof resName === "string" && resName.includes(".")) {
|
|
162
|
-
affectedResourceNames.add(resName.split(".")[0]);
|
|
163
|
-
}
|
|
164
|
-
for (const name of affectedResourceNames) {
|
|
165
|
-
engine.markDataSourceDirty(dataSourceKey, name);
|
|
166
|
-
}
|
|
167
|
-
(_b = (_a = engine.emitter) == null ? void 0 : _a.emit) == null ? void 0 : _b.call(_a, import_viewEvents.DATA_SOURCE_DIRTY_EVENT, {
|
|
168
|
-
dataSourceKey,
|
|
169
|
-
resourceNames: Array.from(affectedResourceNames)
|
|
154
|
+
(0, import_dataSourceDirty.markDataSourceDirty)({
|
|
155
|
+
engine: this.context.engine,
|
|
156
|
+
dataSourceKey: this.getDataSourceKey(),
|
|
157
|
+
resourceName: resourceName || this.getResourceName(),
|
|
158
|
+
includePreviousEngines: true
|
|
170
159
|
});
|
|
171
160
|
}
|
|
172
161
|
setSourceId(sourceId) {
|
|
@@ -42,6 +42,7 @@ __export(multiRecordResource_exports, {
|
|
|
42
42
|
module.exports = __toCommonJS(multiRecordResource_exports);
|
|
43
43
|
var import_reactive = require("@formily/reactive");
|
|
44
44
|
var import_lodash = __toESM(require("lodash"));
|
|
45
|
+
var import_dirtyAwareApiClient = require("../utils/dirtyAwareApiClient");
|
|
45
46
|
var import_baseRecordResource = require("./baseRecordResource");
|
|
46
47
|
const _MultiRecordResource = class _MultiRecordResource extends import_baseRecordResource.BaseRecordResource {
|
|
47
48
|
_data = import_reactive.observable.ref([]);
|
|
@@ -130,7 +131,10 @@ const _MultiRecordResource = class _MultiRecordResource extends import_baseRecor
|
|
|
130
131
|
}
|
|
131
132
|
async create(data, options) {
|
|
132
133
|
const config = this.mergeRequestConfig({ data }, this.createActionOptions, options);
|
|
133
|
-
const res = await this.runAction("create",
|
|
134
|
+
const res = await this.runAction("create", {
|
|
135
|
+
...config,
|
|
136
|
+
[import_dirtyAwareApiClient.SKIP_DATA_SOURCE_DIRTY]: true
|
|
137
|
+
});
|
|
134
138
|
this.markDataSourceDirty();
|
|
135
139
|
this.emit("saved", data);
|
|
136
140
|
if ((options == null ? void 0 : options.refresh) !== false) {
|
|
@@ -161,7 +165,10 @@ const _MultiRecordResource = class _MultiRecordResource extends import_baseRecor
|
|
|
161
165
|
this.updateActionOptions,
|
|
162
166
|
options
|
|
163
167
|
);
|
|
164
|
-
await this.runAction("update",
|
|
168
|
+
await this.runAction("update", {
|
|
169
|
+
...config,
|
|
170
|
+
[import_dirtyAwareApiClient.SKIP_DATA_SOURCE_DIRTY]: true
|
|
171
|
+
});
|
|
165
172
|
this.markDataSourceDirty();
|
|
166
173
|
this.emit("saved", data);
|
|
167
174
|
await this.refresh();
|
|
@@ -182,7 +189,10 @@ const _MultiRecordResource = class _MultiRecordResource extends import_baseRecor
|
|
|
182
189
|
},
|
|
183
190
|
options
|
|
184
191
|
);
|
|
185
|
-
await this.runAction("destroy",
|
|
192
|
+
await this.runAction("destroy", {
|
|
193
|
+
...config,
|
|
194
|
+
[import_dirtyAwareApiClient.SKIP_DATA_SOURCE_DIRTY]: true
|
|
195
|
+
});
|
|
186
196
|
this.markDataSourceDirty();
|
|
187
197
|
const currentPage = this.getPage();
|
|
188
198
|
const lastPage = Math.ceil((this.getCount() - import_lodash.default.castArray(filterByTk).length) / this.getPageSize());
|
|
@@ -41,6 +41,7 @@ __export(singleRecordResource_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(singleRecordResource_exports);
|
|
43
43
|
var import_lodash = __toESM(require("lodash"));
|
|
44
|
+
var import_dirtyAwareApiClient = require("../utils/dirtyAwareApiClient");
|
|
44
45
|
var import_baseRecordResource = require("./baseRecordResource");
|
|
45
46
|
const _SingleRecordResource = class _SingleRecordResource extends import_baseRecordResource.BaseRecordResource {
|
|
46
47
|
isNewRecord = false;
|
|
@@ -68,7 +69,8 @@ const _SingleRecordResource = class _SingleRecordResource extends import_baseRec
|
|
|
68
69
|
}
|
|
69
70
|
const res = await this.runAction(actionName, {
|
|
70
71
|
...config,
|
|
71
|
-
data: result
|
|
72
|
+
data: result,
|
|
73
|
+
[import_dirtyAwareApiClient.SKIP_DATA_SOURCE_DIRTY]: true
|
|
72
74
|
});
|
|
73
75
|
this.markDataSourceDirty();
|
|
74
76
|
this.emit("saved", data);
|
|
@@ -86,7 +88,10 @@ const _SingleRecordResource = class _SingleRecordResource extends import_baseRec
|
|
|
86
88
|
},
|
|
87
89
|
options
|
|
88
90
|
);
|
|
89
|
-
await this.runAction("destroy",
|
|
91
|
+
await this.runAction("destroy", {
|
|
92
|
+
...config,
|
|
93
|
+
[import_dirtyAwareApiClient.SKIP_DATA_SOURCE_DIRTY]: true
|
|
94
|
+
});
|
|
90
95
|
this.markDataSourceDirty();
|
|
91
96
|
this.setData(null);
|
|
92
97
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
import type { FlowEngine } from '../flowEngine';
|
|
10
|
+
type MarkDataSourceDirtyOptions = {
|
|
11
|
+
engine?: FlowEngine;
|
|
12
|
+
dataSourceKey?: unknown;
|
|
13
|
+
resourceName?: unknown;
|
|
14
|
+
includePreviousEngines?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function getHeaderValue(headers: unknown, name: string): unknown;
|
|
17
|
+
export declare function getDataSourceKeyFromHeaders(headers: unknown): string;
|
|
18
|
+
export declare function getAffectedResourceNames(resourceName: unknown): string[];
|
|
19
|
+
export declare function markDataSourceDirty(options: MarkDataSourceDirtyOptions): string[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
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 __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var dataSourceDirty_exports = {};
|
|
29
|
+
__export(dataSourceDirty_exports, {
|
|
30
|
+
getAffectedResourceNames: () => getAffectedResourceNames,
|
|
31
|
+
getDataSourceKeyFromHeaders: () => getDataSourceKeyFromHeaders,
|
|
32
|
+
getHeaderValue: () => getHeaderValue,
|
|
33
|
+
markDataSourceDirty: () => markDataSourceDirty
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(dataSourceDirty_exports);
|
|
36
|
+
var import_viewEvents = require("../views/viewEvents");
|
|
37
|
+
function getHeaderValue(headers, name) {
|
|
38
|
+
if (!headers || typeof headers !== "object") {
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
const maybeHeaders = headers;
|
|
42
|
+
if (typeof maybeHeaders.get === "function") {
|
|
43
|
+
const value = maybeHeaders.get(name);
|
|
44
|
+
if (value != null && value !== "") {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const lowerName = name.toLowerCase();
|
|
49
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
50
|
+
if (key.toLowerCase() === lowerName) {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
__name(getHeaderValue, "getHeaderValue");
|
|
57
|
+
function getDataSourceKeyFromHeaders(headers) {
|
|
58
|
+
const value = getHeaderValue(headers, "x-data-source");
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
return String(value[0] || "main");
|
|
61
|
+
}
|
|
62
|
+
return value == null || value === "" ? "main" : String(value);
|
|
63
|
+
}
|
|
64
|
+
__name(getDataSourceKeyFromHeaders, "getDataSourceKeyFromHeaders");
|
|
65
|
+
function getAffectedResourceNames(resourceName) {
|
|
66
|
+
const name = String(resourceName || "").trim();
|
|
67
|
+
if (!name) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
const names = /* @__PURE__ */ new Set([name]);
|
|
71
|
+
if (name.includes(".")) {
|
|
72
|
+
names.add(name.split(".")[0]);
|
|
73
|
+
}
|
|
74
|
+
return Array.from(names);
|
|
75
|
+
}
|
|
76
|
+
__name(getAffectedResourceNames, "getAffectedResourceNames");
|
|
77
|
+
function getDirtyTargetEngines(engine, includePreviousEngines) {
|
|
78
|
+
if (!includePreviousEngines) {
|
|
79
|
+
return [engine];
|
|
80
|
+
}
|
|
81
|
+
const engines = [];
|
|
82
|
+
const seen = /* @__PURE__ */ new Set();
|
|
83
|
+
let current = engine;
|
|
84
|
+
let guard = 0;
|
|
85
|
+
while (current && guard++ < 50) {
|
|
86
|
+
if (!seen.has(current)) {
|
|
87
|
+
engines.push(current);
|
|
88
|
+
seen.add(current);
|
|
89
|
+
}
|
|
90
|
+
current = current.previousEngine;
|
|
91
|
+
}
|
|
92
|
+
return engines;
|
|
93
|
+
}
|
|
94
|
+
__name(getDirtyTargetEngines, "getDirtyTargetEngines");
|
|
95
|
+
function markDataSourceDirty(options) {
|
|
96
|
+
var _a, _b, _c, _d;
|
|
97
|
+
const { engine, resourceName, includePreviousEngines } = options;
|
|
98
|
+
if (!(engine == null ? void 0 : engine.markDataSourceDirty)) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const resourceNames = getAffectedResourceNames(resourceName);
|
|
102
|
+
if (!resourceNames.length) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
const dataSourceKey = String(options.dataSourceKey || "main");
|
|
106
|
+
const targetEngines = getDirtyTargetEngines(engine, includePreviousEngines);
|
|
107
|
+
const beforeVersions = /* @__PURE__ */ new Map();
|
|
108
|
+
for (const targetEngine of targetEngines) {
|
|
109
|
+
const versions = /* @__PURE__ */ new Map();
|
|
110
|
+
beforeVersions.set(targetEngine, versions);
|
|
111
|
+
for (const name of resourceNames) {
|
|
112
|
+
versions.set(name, ((_a = targetEngine.getDataSourceDirtyVersion) == null ? void 0 : _a.call(targetEngine, dataSourceKey, name)) || 0);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (const targetEngine of targetEngines) {
|
|
116
|
+
const versions = beforeVersions.get(targetEngine);
|
|
117
|
+
for (const name of resourceNames) {
|
|
118
|
+
const before = (versions == null ? void 0 : versions.get(name)) || 0;
|
|
119
|
+
const current = ((_b = targetEngine.getDataSourceDirtyVersion) == null ? void 0 : _b.call(targetEngine, dataSourceKey, name)) || 0;
|
|
120
|
+
if (current !== before) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
targetEngine.markDataSourceDirty(dataSourceKey, name);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
(_d = (_c = engine.emitter) == null ? void 0 : _c.emit) == null ? void 0 : _d.call(_c, import_viewEvents.DATA_SOURCE_DIRTY_EVENT, {
|
|
127
|
+
dataSourceKey,
|
|
128
|
+
resourceNames
|
|
129
|
+
});
|
|
130
|
+
return resourceNames;
|
|
131
|
+
}
|
|
132
|
+
__name(markDataSourceDirty, "markDataSourceDirty");
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
getAffectedResourceNames,
|
|
136
|
+
getDataSourceKeyFromHeaders,
|
|
137
|
+
getHeaderValue,
|
|
138
|
+
markDataSourceDirty
|
|
139
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
import type { FlowContext } from '../flowContext';
|
|
10
|
+
export declare const SKIP_DATA_SOURCE_DIRTY = "__nocobaseSkipDataSourceDirty";
|
|
11
|
+
export declare function getDirtyAwareApiClient(value: unknown, context: FlowContext): unknown;
|