@nocobase/plugin-flow-engine 2.3.0-alpha.1 → 2.3.0-beta.2
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/dist/ai/ai-employees/nathan/prompt.md +2 -0
- package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +1 -0
- package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/patchJSCode.js +2 -2
- package/dist/ai/docs/runjs/context/ai.md +194 -4
- package/dist/externalVersion.js +9 -9
- package/dist/locale/en-US.json +2 -0
- package/dist/locale/index.d.ts +4 -0
- package/dist/locale/zh-CN.json +2 -0
- package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
- package/dist/node_modules/acorn/package.json +1 -1
- package/dist/node_modules/acorn-jsx/package.json +1 -1
- package/dist/node_modules/acorn-walk/package.json +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/builder.js +5 -0
- package/dist/server/flow-surfaces/catalog.js +27 -8
- package/dist/server/flow-surfaces/configure-options.js +17 -1
- package/dist/server/flow-surfaces/field-binding-registry.js +9 -8
- package/dist/server/flow-surfaces/service-utils.d.ts +1 -0
- package/dist/server/flow-surfaces/service-utils.js +17 -0
- package/dist/server/flow-surfaces/service.js +9 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +7 -0
- package/dist/server/plugin.d.ts +13 -0
- package/dist/server/plugin.js +90 -3
- package/dist/server/repository.d.ts +12 -0
- package/dist/server/repository.js +39 -2
- package/dist/server/template/context-keys.d.ts +14 -0
- package/dist/server/template/context-keys.js +86 -0
- package/dist/server/template/contexts.d.ts +5 -8
- package/dist/server/template/contexts.js +43 -51
- package/dist/server/template/resolver.d.ts +5 -13
- package/dist/server/template/resolver.js +188 -257
- package/dist/server/template/variable-expression.d.ts +72 -0
- package/dist/server/template/variable-expression.js +597 -0
- package/dist/server/variables/allow-list.d.ts +49 -0
- package/dist/server/variables/allow-list.js +492 -0
- package/dist/server/variables/form-item-record-slot-resolvers.d.ts +10 -0
- package/dist/server/variables/form-item-record-slot-resolvers.js +280 -0
- package/dist/server/variables/record-bindings.d.ts +42 -0
- package/dist/server/variables/record-bindings.js +196 -0
- package/dist/server/variables/record-projection.d.ts +10 -0
- package/dist/server/variables/record-projection.js +140 -0
- package/dist/server/variables/record-slot-policy.d.ts +23 -0
- package/dist/server/variables/record-slot-policy.js +100 -0
- package/dist/server/variables/record-slot-resolvers.d.ts +46 -0
- package/dist/server/variables/record-slot-resolvers.js +115 -0
- package/dist/server/variables/records.d.ts +49 -2
- package/dist/server/variables/records.js +309 -18
- package/dist/server/variables/registry.d.ts +33 -10
- package/dist/server/variables/registry.js +197 -362
- package/dist/server/variables/resolve.d.ts +20 -2
- package/dist/server/variables/resolve.js +85 -13
- package/dist/server/variables/runjs-variable-dependencies.d.ts +23 -0
- package/dist/server/variables/runjs-variable-dependencies.js +407 -0
- package/dist/server/variables/selects.js +6 -3
- package/dist/server/variables/utils.d.ts +3 -6
- package/dist/server/variables/utils.js +50 -111
- package/package.json +2 -2
|
@@ -7,15 +7,33 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import type { ResourcerContext } from '@nocobase/resourcer';
|
|
10
|
+
import { type AnalyzedTemplate, type ResolvePathPolicy } from '../template/variable-expression';
|
|
10
11
|
import { JSONValue } from '../template/resolver';
|
|
11
|
-
type
|
|
12
|
+
import { type RecordBindingPlan } from './record-bindings';
|
|
13
|
+
export type ResolveBatchItem = {
|
|
12
14
|
id?: string | number;
|
|
13
15
|
template: JSONValue;
|
|
14
16
|
contextParams?: Record<string, unknown>;
|
|
15
17
|
};
|
|
18
|
+
export type AnalyzedResolveBatchItem = ResolveBatchItem & {
|
|
19
|
+
analysis: AnalyzedTemplate;
|
|
20
|
+
bindingPlan: RecordBindingPlan;
|
|
21
|
+
policy: ResolvePathPolicy;
|
|
22
|
+
};
|
|
16
23
|
export declare function resolveVariablesTemplate(ctx: ResourcerContext, template: JSONValue, contextParams?: Record<string, unknown>): Promise<any>;
|
|
24
|
+
export declare function isLegacyVariableTemplateSafe(template: JSONValue): boolean;
|
|
25
|
+
export declare function resolveFlowModelVariablesTemplate(ctx: ResourcerContext, options: {
|
|
26
|
+
contractRd?: string | number;
|
|
27
|
+
contextParams?: Record<string, unknown>;
|
|
28
|
+
rd?: string | number;
|
|
29
|
+
template: JSONValue;
|
|
30
|
+
}): Promise<any>;
|
|
31
|
+
export declare function resolveAnalyzedVariablesTemplate(ctx: ResourcerContext, analysis: AnalyzedTemplate, policy: ResolvePathPolicy, bindingPlan: RecordBindingPlan): Promise<any>;
|
|
17
32
|
export declare function resolveVariablesBatch(ctx: ResourcerContext, items: ResolveBatchItem[]): Promise<{
|
|
18
33
|
id?: string | number;
|
|
19
34
|
data: unknown;
|
|
20
35
|
}[]>;
|
|
21
|
-
export {
|
|
36
|
+
export declare function resolveAnalyzedVariablesBatch(ctx: ResourcerContext, items: AnalyzedResolveBatchItem[]): Promise<{
|
|
37
|
+
id?: string | number;
|
|
38
|
+
data: unknown;
|
|
39
|
+
}[]>;
|
|
@@ -26,15 +26,27 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
27
|
var resolve_exports = {};
|
|
28
28
|
__export(resolve_exports, {
|
|
29
|
+
isLegacyVariableTemplateSafe: () => isLegacyVariableTemplateSafe,
|
|
30
|
+
resolveAnalyzedVariablesBatch: () => resolveAnalyzedVariablesBatch,
|
|
31
|
+
resolveAnalyzedVariablesTemplate: () => resolveAnalyzedVariablesTemplate,
|
|
32
|
+
resolveFlowModelVariablesTemplate: () => resolveFlowModelVariablesTemplate,
|
|
29
33
|
resolveVariablesBatch: () => resolveVariablesBatch,
|
|
30
34
|
resolveVariablesTemplate: () => resolveVariablesTemplate
|
|
31
35
|
});
|
|
32
36
|
module.exports = __toCommonJS(resolve_exports);
|
|
33
37
|
var import_contexts = require("../template/contexts");
|
|
34
38
|
var import_resolver = require("../template/resolver");
|
|
39
|
+
var import_allow_list = require("./allow-list");
|
|
40
|
+
var import_record_bindings = require("./record-bindings");
|
|
35
41
|
var import_registry = require("./registry");
|
|
42
|
+
var import_record_slot_policy = require("./record-slot-policy");
|
|
36
43
|
var import_utils = require("./utils");
|
|
37
44
|
const GLOBAL_CONTEXT_KEY = Symbol.for("nocobase.flow-engine.variables.global-context");
|
|
45
|
+
const REQUEST_BOUND_RESOLVE_POLICY = {
|
|
46
|
+
allowAll: true,
|
|
47
|
+
allowedPaths: /* @__PURE__ */ new Set(),
|
|
48
|
+
unrestrictedVariables: /* @__PURE__ */ new Set()
|
|
49
|
+
};
|
|
38
50
|
function getGlobalContext(ctx) {
|
|
39
51
|
var _a, _b;
|
|
40
52
|
const app = ctx.app;
|
|
@@ -44,36 +56,96 @@ function getGlobalContext(ctx) {
|
|
|
44
56
|
return app[GLOBAL_CONTEXT_KEY];
|
|
45
57
|
}
|
|
46
58
|
async function resolveVariablesTemplate(ctx, template, contextParams = {}) {
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
const result = (0, import_allow_list.analyzeVariableTemplateSafely)(template, { mode: "untrusted-request" });
|
|
60
|
+
if (!result.ok) return template;
|
|
61
|
+
const bindingPlan = await createRequestBoundRecordBindingPlan(ctx, result.analysis, contextParams);
|
|
62
|
+
return resolveAnalyzedVariablesTemplate(ctx, result.analysis, REQUEST_BOUND_RESOLVE_POLICY, bindingPlan);
|
|
63
|
+
}
|
|
64
|
+
function isLegacyVariableTemplateSafe(template) {
|
|
65
|
+
const result = (0, import_allow_list.analyzeVariableTemplateSafely)(template, { mode: "untrusted-request" });
|
|
66
|
+
return result.ok && result.analysis.supported && result.analysis.paths.length === 0;
|
|
67
|
+
}
|
|
68
|
+
async function resolveFlowModelVariablesTemplate(ctx, options) {
|
|
69
|
+
if (!await (0, import_allow_list.resolveFlowModelNodeFromRequestRd)(ctx, options.rd)) return;
|
|
70
|
+
const authorization = await (0, import_allow_list.authorizeVariablesResolve)(ctx, options);
|
|
71
|
+
if (!authorization.allowed || !authorization.flowModelUid) return;
|
|
72
|
+
const resolved = await resolveAnalyzedVariablesTemplate(
|
|
73
|
+
ctx,
|
|
74
|
+
authorization.analysis,
|
|
75
|
+
authorization.policy,
|
|
76
|
+
authorization.bindingPlan
|
|
77
|
+
);
|
|
78
|
+
const remaining = (0, import_allow_list.analyzeVariableTemplateSafely)(resolved, { mode: "untrusted-request" });
|
|
79
|
+
if (!remaining.ok || !remaining.analysis.supported || remaining.analysis.paths.length) return;
|
|
80
|
+
return resolved;
|
|
81
|
+
}
|
|
82
|
+
async function createRequestBoundRecordBindingPlan(ctx, analysis, contextParams) {
|
|
83
|
+
const policies = await (0, import_record_slot_policy.compileRecordSlotPolicies)(analysis, { app: ctx.app, ctx });
|
|
84
|
+
return (0, import_record_bindings.planRecordBindings)({
|
|
85
|
+
contextParams,
|
|
86
|
+
koaCtx: ctx,
|
|
87
|
+
policies,
|
|
88
|
+
usage: analysis.usage
|
|
89
|
+
});
|
|
49
90
|
}
|
|
50
|
-
async function
|
|
91
|
+
async function resolveAnalyzedVariablesTemplate(ctx, analysis, policy, bindingPlan) {
|
|
92
|
+
await (0, import_utils.prefetchRecordsForResolve)(ctx, bindingPlan.bindings);
|
|
93
|
+
return resolveAnalyzedVariablesTemplateWithPrefetchedRecords(ctx, analysis, policy, bindingPlan);
|
|
94
|
+
}
|
|
95
|
+
async function resolveAnalyzedVariablesTemplateWithPrefetchedRecords(ctx, analysis, policy, bindingPlan) {
|
|
51
96
|
const requestCtx = new import_contexts.HttpRequestContext(ctx);
|
|
52
97
|
requestCtx.delegate(getGlobalContext(ctx));
|
|
53
|
-
await import_registry.variables.
|
|
54
|
-
return (0, import_resolver.
|
|
98
|
+
await import_registry.variables.attachUsedVariablesFromPlan(requestCtx, ctx, analysis.usage, bindingPlan);
|
|
99
|
+
return (0, import_resolver.resolveAnalyzedJsonTemplate)(analysis, requestCtx, policy);
|
|
55
100
|
}
|
|
56
101
|
async function resolveVariablesBatch(ctx, items) {
|
|
102
|
+
var _a;
|
|
103
|
+
const analyzedItems = [];
|
|
104
|
+
const results = [];
|
|
105
|
+
for (const [index, item] of items.entries()) {
|
|
106
|
+
const result = (0, import_allow_list.analyzeVariableTemplateSafely)((item == null ? void 0 : item.template) ?? {}, { mode: "untrusted-request" });
|
|
107
|
+
if (!result.ok) {
|
|
108
|
+
results[index] = { id: item == null ? void 0 : item.id, data: (item == null ? void 0 : item.template) ?? {} };
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
analyzedItems.push({
|
|
112
|
+
...item,
|
|
113
|
+
id: index,
|
|
114
|
+
analysis: result.analysis,
|
|
115
|
+
bindingPlan: await createRequestBoundRecordBindingPlan(ctx, result.analysis, item.contextParams || {}),
|
|
116
|
+
policy: REQUEST_BOUND_RESOLVE_POLICY
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const resolvedItems = await resolveAnalyzedVariablesBatch(ctx, analyzedItems);
|
|
120
|
+
for (const item of resolvedItems) {
|
|
121
|
+
const index = Number(item.id);
|
|
122
|
+
results[index] = { id: (_a = items[index]) == null ? void 0 : _a.id, data: item.data };
|
|
123
|
+
}
|
|
124
|
+
return results.filter((item) => !!item);
|
|
125
|
+
}
|
|
126
|
+
async function resolveAnalyzedVariablesBatch(ctx, items) {
|
|
57
127
|
await (0, import_utils.prefetchRecordsForResolve)(
|
|
58
128
|
ctx,
|
|
59
|
-
items.
|
|
60
|
-
template: (item == null ? void 0 : item.template) ?? {},
|
|
61
|
-
contextParams: (item == null ? void 0 : item.contextParams) || {}
|
|
62
|
-
}))
|
|
129
|
+
items.flatMap((item) => item.bindingPlan.bindings)
|
|
63
130
|
);
|
|
64
131
|
const results = [];
|
|
65
132
|
for (const item of items) {
|
|
66
|
-
const data = await
|
|
133
|
+
const data = await resolveAnalyzedVariablesTemplateWithPrefetchedRecords(
|
|
67
134
|
ctx,
|
|
68
|
-
|
|
69
|
-
|
|
135
|
+
item.analysis,
|
|
136
|
+
item.policy,
|
|
137
|
+
item.bindingPlan
|
|
70
138
|
);
|
|
71
|
-
results.push({ id: item
|
|
139
|
+
results.push({ id: item.id, data });
|
|
72
140
|
}
|
|
73
141
|
return results;
|
|
74
142
|
}
|
|
75
143
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
144
|
0 && (module.exports = {
|
|
145
|
+
isLegacyVariableTemplateSafe,
|
|
146
|
+
resolveAnalyzedVariablesBatch,
|
|
147
|
+
resolveAnalyzedVariablesTemplate,
|
|
148
|
+
resolveFlowModelVariablesTemplate,
|
|
77
149
|
resolveVariablesBatch,
|
|
78
150
|
resolveVariablesTemplate
|
|
79
151
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export type PreparedFlowModelVariableSource = Readonly<{
|
|
10
|
+
ok: true;
|
|
11
|
+
runJsTemplates: readonly string[];
|
|
12
|
+
templateSource: unknown;
|
|
13
|
+
}> | Readonly<{
|
|
14
|
+
ok: false;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const MAX_FLOW_MODEL_VARIABLE_SOURCE_DEPTH = 128;
|
|
17
|
+
export declare const MAX_FLOW_MODEL_VARIABLE_SOURCE_NODES = 10000;
|
|
18
|
+
export declare const MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH: number;
|
|
19
|
+
export declare const MAX_FLOW_MODEL_VARIABLE_TOTAL_STRING_LENGTH: number;
|
|
20
|
+
export declare function prepareFlowModelVariableSource(value: unknown, options?: Readonly<{
|
|
21
|
+
isRunJsValuePath?: (pathTail: readonly string[]) => boolean;
|
|
22
|
+
}>): PreparedFlowModelVariableSource;
|
|
23
|
+
export declare function collectPersistedRunJsVariableTemplates(value: unknown): string[];
|
|
@@ -0,0 +1,407 @@
|
|
|
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 __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var runjs_variable_dependencies_exports = {};
|
|
28
|
+
__export(runjs_variable_dependencies_exports, {
|
|
29
|
+
MAX_FLOW_MODEL_VARIABLE_SOURCE_DEPTH: () => MAX_FLOW_MODEL_VARIABLE_SOURCE_DEPTH,
|
|
30
|
+
MAX_FLOW_MODEL_VARIABLE_SOURCE_NODES: () => MAX_FLOW_MODEL_VARIABLE_SOURCE_NODES,
|
|
31
|
+
MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH: () => MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH,
|
|
32
|
+
MAX_FLOW_MODEL_VARIABLE_TOTAL_STRING_LENGTH: () => MAX_FLOW_MODEL_VARIABLE_TOTAL_STRING_LENGTH,
|
|
33
|
+
collectPersistedRunJsVariableTemplates: () => collectPersistedRunJsVariableTemplates,
|
|
34
|
+
prepareFlowModelVariableSource: () => prepareFlowModelVariableSource
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(runjs_variable_dependencies_exports);
|
|
37
|
+
var import_bindings = require("../flow-surfaces/runjs-authoring/ast/bindings");
|
|
38
|
+
var import_source = require("../flow-surfaces/runjs-authoring/ast/source");
|
|
39
|
+
var import_static_bindings = require("../flow-surfaces/runjs-authoring/ast/static-bindings");
|
|
40
|
+
var import_static_values = require("../flow-surfaces/runjs-authoring/ast/static-values");
|
|
41
|
+
var import_parser = require("../flow-surfaces/runjs-authoring/ast/parser");
|
|
42
|
+
var import_walk = require("../flow-surfaces/runjs-authoring/ast/walk");
|
|
43
|
+
var import_constants = require("../flow-surfaces/runjs-authoring/runtime/constants");
|
|
44
|
+
var import_variable_expression = require("../template/variable-expression");
|
|
45
|
+
const RUNJS_VALUE_KEYS = /* @__PURE__ */ new Set(["code", "version"]);
|
|
46
|
+
const RUNJS_PATH_SUFFIXES = /* @__PURE__ */ new Set(["stepParams.jsSettings.runJs", "stepParams.clickSettings.runJs"]);
|
|
47
|
+
const MUTATING_CTX_METHODS = /* @__PURE__ */ new Set(["__defineGetter__", "__defineSetter__"]);
|
|
48
|
+
const GLOBAL_OBJECT_NAMES = /* @__PURE__ */ new Set(["globalThis"]);
|
|
49
|
+
const DYNAMIC_CODE_EXECUTION_NAMES = /* @__PURE__ */ new Set(["eval", "Function"]);
|
|
50
|
+
const MAX_FLOW_MODEL_VARIABLE_SOURCE_DEPTH = 128;
|
|
51
|
+
const MAX_FLOW_MODEL_VARIABLE_SOURCE_NODES = 1e4;
|
|
52
|
+
const MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH = 256 * 1024;
|
|
53
|
+
const MAX_FLOW_MODEL_VARIABLE_TOTAL_STRING_LENGTH = 1024 * 1024;
|
|
54
|
+
function getEnumerableDataEntries(value) {
|
|
55
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
56
|
+
const entries = [];
|
|
57
|
+
for (const key of Object.keys(descriptors)) {
|
|
58
|
+
const descriptor = descriptors[key];
|
|
59
|
+
if (!descriptor.enumerable) continue;
|
|
60
|
+
if (!Object.prototype.hasOwnProperty.call(descriptor, "value")) {
|
|
61
|
+
throw new TypeError("FlowModel variable source must not contain accessors");
|
|
62
|
+
}
|
|
63
|
+
entries.push([key, descriptor.value]);
|
|
64
|
+
}
|
|
65
|
+
return { descriptors, entries };
|
|
66
|
+
}
|
|
67
|
+
function readPersistedRunJsValue(entries) {
|
|
68
|
+
if (!entries.length || entries.some(([key]) => !RUNJS_VALUE_KEYS.has(key))) return;
|
|
69
|
+
const values = new Map(entries);
|
|
70
|
+
const code = values.get("code");
|
|
71
|
+
const version = values.get("version");
|
|
72
|
+
if (typeof code !== "string" || version != null && typeof version !== "string") return;
|
|
73
|
+
return { code, version };
|
|
74
|
+
}
|
|
75
|
+
function isPersistedRunJsPath(pathTail) {
|
|
76
|
+
return RUNJS_PATH_SUFFIXES.has(pathTail.slice(-3).join("."));
|
|
77
|
+
}
|
|
78
|
+
function createTraversalContainer(input, descriptors) {
|
|
79
|
+
var _a;
|
|
80
|
+
if (!Array.isArray(input)) return /* @__PURE__ */ Object.create(null);
|
|
81
|
+
const length = (_a = descriptors.length) == null ? void 0 : _a.value;
|
|
82
|
+
if (!Number.isInteger(length) || length < 0 || length > MAX_FLOW_MODEL_VARIABLE_SOURCE_NODES) {
|
|
83
|
+
throw new RangeError("FlowModel variable source array exceeds its limit");
|
|
84
|
+
}
|
|
85
|
+
return new Array(length);
|
|
86
|
+
}
|
|
87
|
+
function defineTraversalValue(parent, key, value) {
|
|
88
|
+
Object.defineProperty(parent, key, {
|
|
89
|
+
configurable: true,
|
|
90
|
+
enumerable: true,
|
|
91
|
+
value,
|
|
92
|
+
writable: true
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function functionBindsCtxParameter(node, cache) {
|
|
96
|
+
if (!(0, import_bindings.isAstFunctionLike)(node)) return false;
|
|
97
|
+
const objectNode = node;
|
|
98
|
+
const cached = cache.get(objectNode);
|
|
99
|
+
if (typeof cached === "boolean") return cached;
|
|
100
|
+
let bindsCtx = false;
|
|
101
|
+
for (const parameter of node.params || []) {
|
|
102
|
+
(0, import_static_values.collectAstPatternBindingIdentifiers)(parameter, (name) => {
|
|
103
|
+
if (name === "ctx") bindsCtx = true;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
cache.set(objectNode, bindsCtx);
|
|
107
|
+
return bindsCtx;
|
|
108
|
+
}
|
|
109
|
+
function hasCtxParameterInFunctionAncestors(ancestors, cache) {
|
|
110
|
+
return ancestors.some((ancestor) => functionBindsCtxParameter(ancestor, cache));
|
|
111
|
+
}
|
|
112
|
+
function getDirectCtxMethodName(node, identifierBindings) {
|
|
113
|
+
const member = (0, import_bindings.unwrapAstChainExpression)(node);
|
|
114
|
+
if ((member == null ? void 0 : member.type) !== "MemberExpression" || !(0, import_static_values.isUnshadowedCtxIdentifier)(member.object, identifierBindings)) return;
|
|
115
|
+
return (0, import_static_values.getAstStaticPropertyName)(member);
|
|
116
|
+
}
|
|
117
|
+
function isCtxRootedMember(node, identifierBindings) {
|
|
118
|
+
const member = (0, import_bindings.unwrapAstChainExpression)(node);
|
|
119
|
+
if ((member == null ? void 0 : member.type) !== "MemberExpression") return false;
|
|
120
|
+
const root = (0, import_static_values.getAstMemberRootIdentifier)(member);
|
|
121
|
+
return (root == null ? void 0 : root.name) === "ctx" && !(0, import_static_values.hasAstActiveBinding)("ctx", root.index, identifierBindings);
|
|
122
|
+
}
|
|
123
|
+
function isCtxMutationTarget(target, identifierBindings) {
|
|
124
|
+
const node = (0, import_bindings.unwrapAstChainExpression)(target);
|
|
125
|
+
if (!node) return false;
|
|
126
|
+
if (node.type === "Identifier") return (0, import_static_values.isUnshadowedCtxIdentifier)(node, identifierBindings);
|
|
127
|
+
if (node.type === "MemberExpression") return isCtxRootedMember(node, identifierBindings);
|
|
128
|
+
if (node.type === "AssignmentPattern") return isCtxMutationTarget(node.left, identifierBindings);
|
|
129
|
+
if (node.type === "RestElement") return isCtxMutationTarget(node.argument, identifierBindings);
|
|
130
|
+
if (node.type === "ArrayPattern") {
|
|
131
|
+
return (node.elements || []).some((element) => isCtxMutationTarget(element, identifierBindings));
|
|
132
|
+
}
|
|
133
|
+
if (node.type !== "ObjectPattern") return false;
|
|
134
|
+
return (node.properties || []).some((propertyValue) => {
|
|
135
|
+
const property = propertyValue;
|
|
136
|
+
if ((property == null ? void 0 : property.type) === "RestElement") {
|
|
137
|
+
return isCtxMutationTarget(property.argument, identifierBindings);
|
|
138
|
+
}
|
|
139
|
+
return (property == null ? void 0 : property.type) === "Property" && isCtxMutationTarget(property.value, identifierBindings);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function isNonReferenceIdentifier(node, parent) {
|
|
143
|
+
if (!parent) return false;
|
|
144
|
+
if (parent.type === "MemberExpression" && parent.property === node && !parent.computed) return true;
|
|
145
|
+
if (parent.type === "Property" && parent.key === node && !parent.computed && !parent.shorthand) return true;
|
|
146
|
+
if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return (parent.type === "LabeledStatement" || parent.type === "BreakStatement" || parent.type === "ContinueStatement") && parent.value === node;
|
|
150
|
+
}
|
|
151
|
+
function thisUsesTopLevelBinding(ancestors) {
|
|
152
|
+
for (let index = 0; index < ancestors.length; index += 1) {
|
|
153
|
+
const ancestor = ancestors[index];
|
|
154
|
+
if ((0, import_bindings.isAstFunctionLike)(ancestor) && ancestor.type !== "ArrowFunctionExpression") return false;
|
|
155
|
+
if (ancestor.type === "StaticBlock") return false;
|
|
156
|
+
if (ancestor.type === "PropertyDefinition" && (0, import_bindings.unwrapAstChainExpression)(ancestor.value) === ancestors[index + 1]) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
function hasUnsafeCtxUsage(ast, identifierBindings) {
|
|
163
|
+
let unsafe = false;
|
|
164
|
+
(0, import_walk.walkAstAncestor)(ast, {
|
|
165
|
+
Identifier(node, ancestors) {
|
|
166
|
+
const parent = ancestors[ancestors.length - 2];
|
|
167
|
+
if (isNonReferenceIdentifier(node, parent)) return;
|
|
168
|
+
if (node.name && (GLOBAL_OBJECT_NAMES.has(node.name) || DYNAMIC_CODE_EXECUTION_NAMES.has(node.name)) && !(0, import_static_values.hasAstActiveBinding)(node.name, node.start || 0, identifierBindings)) {
|
|
169
|
+
unsafe = true;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!(0, import_static_values.isUnshadowedCtxIdentifier)(node, identifierBindings)) return;
|
|
173
|
+
if ((parent == null ? void 0 : parent.type) === "MemberExpression" && (0, import_bindings.unwrapAstChainExpression)(parent.object) === node) return;
|
|
174
|
+
unsafe = true;
|
|
175
|
+
},
|
|
176
|
+
ThisExpression(_node, ancestors) {
|
|
177
|
+
if (thisUsesTopLevelBinding(ancestors)) unsafe = true;
|
|
178
|
+
},
|
|
179
|
+
WithStatement() {
|
|
180
|
+
unsafe = true;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return unsafe;
|
|
184
|
+
}
|
|
185
|
+
function hasCtxMutation(ast, identifierBindings) {
|
|
186
|
+
let mutated = false;
|
|
187
|
+
(0, import_walk.walkAstSimple)(ast, {
|
|
188
|
+
AssignmentExpression(node) {
|
|
189
|
+
if (isCtxMutationTarget(node.left, identifierBindings)) mutated = true;
|
|
190
|
+
},
|
|
191
|
+
CallExpression(node) {
|
|
192
|
+
const callee = (0, import_bindings.unwrapAstChainExpression)(node.callee);
|
|
193
|
+
if ((callee == null ? void 0 : callee.type) === "MemberExpression" && MUTATING_CTX_METHODS.has((0, import_static_values.getAstStaticPropertyName)(callee)) && isCtxRootedMember(callee, identifierBindings)) {
|
|
194
|
+
mutated = true;
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
ForInStatement(node) {
|
|
198
|
+
if (isCtxMutationTarget(node.left, identifierBindings)) mutated = true;
|
|
199
|
+
},
|
|
200
|
+
ForOfStatement(node) {
|
|
201
|
+
if (isCtxMutationTarget(node.left, identifierBindings)) mutated = true;
|
|
202
|
+
},
|
|
203
|
+
UnaryExpression(node) {
|
|
204
|
+
if (node.operator === "delete" && isCtxMutationTarget(node.argument, identifierBindings)) {
|
|
205
|
+
mutated = true;
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
UpdateExpression(node) {
|
|
209
|
+
if (isCtxMutationTarget(node.argument, identifierBindings)) mutated = true;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
return mutated;
|
|
213
|
+
}
|
|
214
|
+
function createValidatedGetVarTemplate(value, code) {
|
|
215
|
+
var _a;
|
|
216
|
+
const path = (_a = (0, import_static_values.resolveAstStaticStringValue)(value, code)) == null ? void 0 : _a.trim();
|
|
217
|
+
if (!path) return;
|
|
218
|
+
const template = `{{${path}}}`;
|
|
219
|
+
const analysis = (0, import_variable_expression.analyzeVariableTemplate)(template, { mode: "flow-model" });
|
|
220
|
+
if (analysis.errors.length !== 0 || analysis.paths.length !== 1 || analysis.value.kind !== "string") return;
|
|
221
|
+
if (analysis.value.expressions.length !== 1) return;
|
|
222
|
+
const expression = analysis.value.expressions[0];
|
|
223
|
+
const variablePath = expression.paths[0];
|
|
224
|
+
if (!variablePath || !expression.supported || expression.paths.length !== 1 || expression.expressionSpan.start !== 2 || expression.expressionSpan.end !== 2 + path.length || expression.placeholderSpan.start !== 0 || expression.placeholderSpan.end !== template.length || variablePath.span.start !== 2 || variablePath.span.end !== 2 + path.length) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
return `{{ ${path} }}`;
|
|
228
|
+
}
|
|
229
|
+
function resolveStaticJsonValue(node, code) {
|
|
230
|
+
var _a;
|
|
231
|
+
const valueNode = (0, import_bindings.unwrapAstChainExpression)(node);
|
|
232
|
+
if (!valueNode) return { ok: false };
|
|
233
|
+
if (valueNode.type === "Literal") {
|
|
234
|
+
const literalValue = valueNode.value;
|
|
235
|
+
if (literalValue === null) return { ok: true, value: null };
|
|
236
|
+
if (typeof literalValue === "string") return { ok: true, value: literalValue };
|
|
237
|
+
if (typeof literalValue === "boolean") return { ok: true, value: literalValue };
|
|
238
|
+
if (typeof literalValue === "number" && Number.isFinite(literalValue)) return { ok: true, value: literalValue };
|
|
239
|
+
return { ok: false };
|
|
240
|
+
}
|
|
241
|
+
if (valueNode.type === "TemplateLiteral" && !((_a = valueNode.expressions) == null ? void 0 : _a.length)) {
|
|
242
|
+
const value2 = (0, import_static_values.resolveAstStaticStringValue)(valueNode, code);
|
|
243
|
+
return typeof value2 === "string" ? { ok: true, value: value2 } : { ok: false };
|
|
244
|
+
}
|
|
245
|
+
if (valueNode.type === "UnaryExpression" && valueNode.operator === "-") {
|
|
246
|
+
const argument = (0, import_bindings.unwrapAstChainExpression)(valueNode.argument);
|
|
247
|
+
return (argument == null ? void 0 : argument.type) === "Literal" && typeof argument.value === "number" && Number.isFinite(argument.value) ? { ok: true, value: -argument.value } : { ok: false };
|
|
248
|
+
}
|
|
249
|
+
if (valueNode.type === "ArrayExpression") {
|
|
250
|
+
const value2 = [];
|
|
251
|
+
for (const element of valueNode.elements || []) {
|
|
252
|
+
if (!element || element.type === "SpreadElement") return { ok: false };
|
|
253
|
+
const resolved = resolveStaticJsonValue(element, code);
|
|
254
|
+
if (!resolved.ok) return resolved;
|
|
255
|
+
value2.push(resolved.value);
|
|
256
|
+
}
|
|
257
|
+
return { ok: true, value: value2 };
|
|
258
|
+
}
|
|
259
|
+
if (valueNode.type !== "ObjectExpression") return { ok: false };
|
|
260
|
+
const value = /* @__PURE__ */ Object.create(null);
|
|
261
|
+
for (const propertyValue of valueNode.properties || []) {
|
|
262
|
+
const property = propertyValue;
|
|
263
|
+
if ((property == null ? void 0 : property.type) !== "Property" || property.computed || property.kind !== "init" || property.method || property.shorthand) {
|
|
264
|
+
return { ok: false };
|
|
265
|
+
}
|
|
266
|
+
const keyNode = (0, import_bindings.unwrapAstChainExpression)(property.key);
|
|
267
|
+
const key = (keyNode == null ? void 0 : keyNode.type) === "Identifier" ? keyNode.name : (keyNode == null ? void 0 : keyNode.type) === "Literal" && (typeof keyNode.value === "string" || typeof keyNode.value === "number") ? String(keyNode.value) : void 0;
|
|
268
|
+
if (typeof key !== "string" || key === "__proto__" || Object.prototype.hasOwnProperty.call(value, key)) {
|
|
269
|
+
return { ok: false };
|
|
270
|
+
}
|
|
271
|
+
const resolved = resolveStaticJsonValue(property.value, code);
|
|
272
|
+
if (!resolved.ok) return resolved;
|
|
273
|
+
value[key] = resolved.value;
|
|
274
|
+
}
|
|
275
|
+
return { ok: true, value };
|
|
276
|
+
}
|
|
277
|
+
function collectValidatedResolveJsonTemplates(value) {
|
|
278
|
+
const analysis = (0, import_variable_expression.analyzeVariableTemplate)(value, { mode: "untrusted-request" });
|
|
279
|
+
if (!analysis.supported || analysis.errors.length) return [];
|
|
280
|
+
const templates = /* @__PURE__ */ new Set();
|
|
281
|
+
const visit = (current) => {
|
|
282
|
+
if (typeof current === "string") {
|
|
283
|
+
if ((0, import_variable_expression.analyzeVariableTemplate)(current, { mode: "untrusted-request" }).paths.length) templates.add(current);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (Array.isArray(current)) {
|
|
287
|
+
current.forEach(visit);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (current && typeof current === "object") Object.values(current).forEach(visit);
|
|
291
|
+
};
|
|
292
|
+
visit(value);
|
|
293
|
+
return Array.from(templates);
|
|
294
|
+
}
|
|
295
|
+
function extractStaticVariableTemplates(code) {
|
|
296
|
+
const parsed = (0, import_parser.parseRunJsAuthoringAst)(code);
|
|
297
|
+
if (!parsed.ast) return [];
|
|
298
|
+
const identifierBindings = (0, import_static_bindings.collectAstIdentifierBindingsFromAst)(parsed.ast, code);
|
|
299
|
+
if (hasUnsafeCtxUsage(parsed.ast, identifierBindings) || hasCtxMutation(parsed.ast, identifierBindings)) {
|
|
300
|
+
return [];
|
|
301
|
+
}
|
|
302
|
+
const functionCtxParameterCache = /* @__PURE__ */ new WeakMap();
|
|
303
|
+
const templates = /* @__PURE__ */ new Set();
|
|
304
|
+
(0, import_walk.walkAstAncestor)(parsed.ast, {
|
|
305
|
+
CallExpression(node, ancestors) {
|
|
306
|
+
var _a, _b;
|
|
307
|
+
const methodName = getDirectCtxMethodName(node.callee, identifierBindings);
|
|
308
|
+
if (hasCtxParameterInFunctionAncestors(ancestors, functionCtxParameterCache)) return;
|
|
309
|
+
if (methodName === "getVar") {
|
|
310
|
+
const template = createValidatedGetVarTemplate((_a = node.arguments) == null ? void 0 : _a[0], code);
|
|
311
|
+
if (template) templates.add(template);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (methodName !== "resolveJsonTemplate" || ((_b = node.arguments) == null ? void 0 : _b.length) !== 1) return;
|
|
315
|
+
const resolved = resolveStaticJsonValue(node.arguments[0], code);
|
|
316
|
+
if (!resolved.ok) return;
|
|
317
|
+
collectValidatedResolveJsonTemplates(resolved.value).forEach((template) => templates.add(template));
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
return Array.from(templates);
|
|
321
|
+
}
|
|
322
|
+
function prepareFlowModelVariableSource(value, options = {}) {
|
|
323
|
+
var _a;
|
|
324
|
+
try {
|
|
325
|
+
const templates = /* @__PURE__ */ new Set();
|
|
326
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
327
|
+
const root = /* @__PURE__ */ Object.create(null);
|
|
328
|
+
const stack = [{ depth: 0, input: value, key: "value", parent: root, pathTail: [] }];
|
|
329
|
+
let scheduledNodes = 1;
|
|
330
|
+
let sourceCount = 0;
|
|
331
|
+
let totalStringLength = 0;
|
|
332
|
+
let totalSourceLength = 0;
|
|
333
|
+
while (stack.length) {
|
|
334
|
+
const frame = stack.pop();
|
|
335
|
+
if (!frame) break;
|
|
336
|
+
const { depth, input, key, parent, pathTail } = frame;
|
|
337
|
+
if (!input || typeof input !== "object") {
|
|
338
|
+
if (typeof input === "string") {
|
|
339
|
+
totalStringLength += input.length;
|
|
340
|
+
if (input.length > MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH || totalStringLength > MAX_FLOW_MODEL_VARIABLE_TOTAL_STRING_LENGTH) {
|
|
341
|
+
return { ok: false };
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
defineTraversalValue(parent, key, input);
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (seen.has(input)) return { ok: false };
|
|
348
|
+
seen.add(input);
|
|
349
|
+
const { descriptors, entries } = getEnumerableDataEntries(input);
|
|
350
|
+
for (const [entryKey] of entries) {
|
|
351
|
+
totalStringLength += entryKey.length;
|
|
352
|
+
if (entryKey.length > MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH || totalStringLength > MAX_FLOW_MODEL_VARIABLE_TOTAL_STRING_LENGTH) {
|
|
353
|
+
return { ok: false };
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const runJsPath = options.isRunJsValuePath ? options.isRunJsValuePath(pathTail) : isPersistedRunJsPath(pathTail);
|
|
357
|
+
const runJs = !Array.isArray(input) && runJsPath ? readPersistedRunJsValue(entries) : void 0;
|
|
358
|
+
const output = createTraversalContainer(input, descriptors);
|
|
359
|
+
defineTraversalValue(parent, key, output);
|
|
360
|
+
if (runJs) {
|
|
361
|
+
scheduledNodes += entries.length;
|
|
362
|
+
sourceCount += 1;
|
|
363
|
+
totalStringLength += runJs.code.length + (((_a = runJs.version) == null ? void 0 : _a.length) || 0);
|
|
364
|
+
totalSourceLength += runJs.code.length;
|
|
365
|
+
if (scheduledNodes > MAX_FLOW_MODEL_VARIABLE_SOURCE_NODES || runJs.code.length > MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH || runJs.version != null && runJs.version.length > MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH || totalStringLength > MAX_FLOW_MODEL_VARIABLE_TOTAL_STRING_LENGTH || sourceCount > import_constants.MAX_RUNJS_SOURCES_PER_REQUEST || runJs.code.length > import_constants.MAX_RUNJS_SOURCE_LENGTH || totalSourceLength > import_constants.MAX_RUNJS_TOTAL_SOURCE_LENGTH) {
|
|
366
|
+
return { ok: false };
|
|
367
|
+
}
|
|
368
|
+
for (const [entryKey, entryValue] of entries) {
|
|
369
|
+
const preparedEntryValue = entryKey === "code" ? runJs.version === "v2" ? "" : (0, import_source.maskJavaScriptComments)(runJs.code) : entryValue;
|
|
370
|
+
defineTraversalValue(output, entryKey, preparedEntryValue);
|
|
371
|
+
}
|
|
372
|
+
extractStaticVariableTemplates(runJs.code).forEach((template) => templates.add(template));
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (entries.length && depth >= MAX_FLOW_MODEL_VARIABLE_SOURCE_DEPTH) return { ok: false };
|
|
376
|
+
scheduledNodes += entries.length;
|
|
377
|
+
if (scheduledNodes > MAX_FLOW_MODEL_VARIABLE_SOURCE_NODES) return { ok: false };
|
|
378
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
379
|
+
const [entryKey, entryValue] = entries[index];
|
|
380
|
+
const nextPath = [...pathTail, entryKey];
|
|
381
|
+
stack.push({
|
|
382
|
+
depth: depth + 1,
|
|
383
|
+
input: entryValue,
|
|
384
|
+
key: entryKey,
|
|
385
|
+
parent: output,
|
|
386
|
+
pathTail: options.isRunJsValuePath ? nextPath : nextPath.slice(-3)
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return { ok: true, runJsTemplates: Array.from(templates), templateSource: root.value };
|
|
391
|
+
} catch {
|
|
392
|
+
return { ok: false };
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function collectPersistedRunJsVariableTemplates(value) {
|
|
396
|
+
const prepared = prepareFlowModelVariableSource(value);
|
|
397
|
+
return prepared.ok ? Array.from(prepared.runJsTemplates) : [];
|
|
398
|
+
}
|
|
399
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
400
|
+
0 && (module.exports = {
|
|
401
|
+
MAX_FLOW_MODEL_VARIABLE_SOURCE_DEPTH,
|
|
402
|
+
MAX_FLOW_MODEL_VARIABLE_SOURCE_NODES,
|
|
403
|
+
MAX_FLOW_MODEL_VARIABLE_STRING_LENGTH,
|
|
404
|
+
MAX_FLOW_MODEL_VARIABLE_TOTAL_STRING_LENGTH,
|
|
405
|
+
collectPersistedRunJsVariableTemplates,
|
|
406
|
+
prepareFlowModelVariableSource
|
|
407
|
+
});
|
|
@@ -30,12 +30,15 @@ __export(selects_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(selects_exports);
|
|
32
32
|
function adjustSelectsForCollection(koaCtx, dataSourceKey, collection, fields, appends) {
|
|
33
|
-
var _a, _b, _c, _d;
|
|
33
|
+
var _a, _b, _c, _d, _e;
|
|
34
34
|
const ds = koaCtx.app.dataSourceManager.get(dataSourceKey || "main");
|
|
35
35
|
const cm = ds.collectionManager;
|
|
36
36
|
const coll = (_b = (_a = cm == null ? void 0 : cm.db) == null ? void 0 : _a.getCollection) == null ? void 0 : _b.call(_a, collection);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
if (!((_c = coll == null ? void 0 : coll.model) == null ? void 0 : _c.rawAttributes)) {
|
|
38
|
+
return { fields, appends };
|
|
39
|
+
}
|
|
40
|
+
const assocKeys = Object.keys(((_d = coll == null ? void 0 : coll.model) == null ? void 0 : _d.associations) || {});
|
|
41
|
+
const rawAttrs = ((_e = coll == null ? void 0 : coll.model) == null ? void 0 : _e.rawAttributes) || {};
|
|
39
42
|
const toCamel = (s) => s.replace(/_([a-zA-Z0-9])/g, (_m, c) => String(c).toUpperCase());
|
|
40
43
|
const toSnake = (s) => s.replace(/([A-Z])/g, "_$1").toLowerCase().replace(/^_/, "");
|
|
41
44
|
const assocMap = /* @__PURE__ */ new Map();
|
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import type { ResourcerContext } from '@nocobase/resourcer';
|
|
10
|
-
import type {
|
|
10
|
+
import type { AuthorizedRecordBinding } from './record-bindings';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Merge record selects for one resolve request and populate the request cache once per target.
|
|
13
13
|
*/
|
|
14
|
-
export declare function prefetchRecordsForResolve(koaCtx: ResourcerContext,
|
|
15
|
-
template: JSONValue;
|
|
16
|
-
contextParams?: Record<string, unknown>;
|
|
17
|
-
}>): Promise<void>;
|
|
14
|
+
export declare function prefetchRecordsForResolve(koaCtx: ResourcerContext, bindings: readonly AuthorizedRecordBinding[]): Promise<void>;
|