@nocobase/plugin-flow-engine 2.1.0-beta.43 → 2.1.0-beta.45
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/client/index.js +1 -1
- package/dist/externalVersion.js +9 -9
- 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/authoring-validation.js +160 -21
- package/dist/server/flow-surfaces/catalog.js +9 -5
- package/dist/server/flow-surfaces/chart-config.js +29 -6
- package/dist/server/flow-surfaces/contract-guard.js +39 -5
- package/dist/server/flow-surfaces/default-block-actions.js +2 -0
- package/dist/server/flow-surfaces/errors.d.ts +15 -0
- package/dist/server/flow-surfaces/errors.js +49 -3
- package/dist/server/flow-surfaces/filter-group.d.ts +7 -1
- package/dist/server/flow-surfaces/filter-group.js +175 -71
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +2 -1
- package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.d.ts +66 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.js +661 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/execution.d.ts +20 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/execution.js +275 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/parser.d.ts +16 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/parser.js +130 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.d.ts +20 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.js +401 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.d.ts +21 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.js +199 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +70 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +895 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.d.ts +23 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.js +618 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.d.ts +196 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.js +1777 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/walk.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/walk.js +55 -0
- package/dist/server/flow-surfaces/runjs-authoring/collectors.d.ts +12 -0
- package/dist/server/flow-surfaces/runjs-authoring/collectors.js +589 -0
- package/dist/server/flow-surfaces/runjs-authoring/index.d.ts +2 -25
- package/dist/server/flow-surfaces/runjs-authoring/index.js +5 -11138
- package/dist/server/flow-surfaces/runjs-authoring/inspect.d.ts +13 -0
- package/dist/server/flow-surfaces/runjs-authoring/inspect.js +149 -0
- package/dist/server/flow-surfaces/runjs-authoring/internal-types.d.ts +333 -0
- package/dist/server/flow-surfaces/runjs-authoring/internal-types.js +36 -0
- package/dist/server/flow-surfaces/runjs-authoring/rules.js +2 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +67 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +757 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.d.ts +22 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.js +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.d.ts +16 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.js +115 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.d.ts +19 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.js +140 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/types.js +24 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.d.ts +138 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.js +1779 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/filter.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +1583 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +195 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +463 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.d.ts +48 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.js +379 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react.d.ts +26 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react.js +1441 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/resource.d.ts +23 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/resource.js +1427 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +889 -0
- package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
- package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.js +40 -0
- package/dist/server/flow-surfaces/runjs-authoring/validators/index.d.ts +12 -0
- package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +887 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +29 -0
- package/dist/server/flow-surfaces/service-helpers.js +105 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +15 -3
- package/dist/server/flow-surfaces/service-utils.js +5 -4
- package/dist/server/flow-surfaces/service.d.ts +4 -0
- package/dist/server/flow-surfaces/service.js +360 -30
- package/dist/server/flow-surfaces/types.d.ts +3 -0
- package/dist/server/repository.d.ts +15 -1
- package/dist/server/repository.js +262 -23
- package/dist/server/template/contexts.d.ts +2 -0
- package/dist/server/template/contexts.js +34 -0
- package/dist/server/template/resolver.js +233 -22
- package/dist/swagger/flow-surfaces.d.ts +175 -0
- package/dist/swagger/flow-surfaces.js +130 -51
- package/dist/swagger/index.d.ts +175 -0
- package/package.json +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
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 { FlowSurfaceErrorItemInput } from '../errors';
|
|
10
|
+
import type { RunJsAuthoringInspectionInput } from './types';
|
|
11
|
+
import type { RunJsAuthoringContext, RunJsSourceBudget } from './internal-types';
|
|
12
|
+
export declare function inspectRunJsAuthoringCodeForWrite(input: RunJsAuthoringInspectionInput, budget?: RunJsSourceBudget, context?: RunJsAuthoringContext): FlowSurfaceErrorItemInput[];
|
|
13
|
+
export declare function inspectRunJsAuthoringCode(input: RunJsAuthoringInspectionInput, context?: RunJsAuthoringContext): FlowSurfaceErrorItemInput[];
|
|
@@ -0,0 +1,149 @@
|
|
|
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 inspect_exports = {};
|
|
28
|
+
__export(inspect_exports, {
|
|
29
|
+
inspectRunJsAuthoringCode: () => inspectRunJsAuthoringCode,
|
|
30
|
+
inspectRunJsAuthoringCodeForWrite: () => inspectRunJsAuthoringCodeForWrite
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(inspect_exports);
|
|
33
|
+
var import_constants = require("./runtime/constants");
|
|
34
|
+
var import_surface = require("./runtime/surface");
|
|
35
|
+
var import_parser = require("./ast/parser");
|
|
36
|
+
var import_errors = require("./runtime/errors");
|
|
37
|
+
var import_source_budget = require("./runtime/source-budget");
|
|
38
|
+
var import_scan = require("./scan");
|
|
39
|
+
var import_validators = require("./validators");
|
|
40
|
+
function inspectRunJsAuthoringCodeForWrite(input, budget, context = {}) {
|
|
41
|
+
const limitResult = (0, import_source_budget.collectRunJsSourceLimitErrors)(input, budget);
|
|
42
|
+
if (limitResult.skipInspection || limitResult.errors.length) {
|
|
43
|
+
return limitResult.errors;
|
|
44
|
+
}
|
|
45
|
+
return inspectRunJsAuthoringCode(input, context);
|
|
46
|
+
}
|
|
47
|
+
function inspectRunJsAuthoringCode(input, context = {}) {
|
|
48
|
+
const errors = [];
|
|
49
|
+
const source = String(input.code || "");
|
|
50
|
+
const modelUse = (0, import_surface.normalizeText)(input.modelUse);
|
|
51
|
+
const surface = (0, import_surface.normalizeText)(input.surface);
|
|
52
|
+
const surfaceStyle = (0, import_surface.resolveSurfaceStyle)(input);
|
|
53
|
+
const sourceLimitResult = (0, import_source_budget.collectRunJsSourceLimitErrors)(input);
|
|
54
|
+
if (sourceLimitResult.skipInspection || sourceLimitResult.errors.length) {
|
|
55
|
+
return sourceLimitResult.errors;
|
|
56
|
+
}
|
|
57
|
+
if (surface && !import_constants.SURFACE_STYLE_BY_ID[surface]) {
|
|
58
|
+
errors.push(
|
|
59
|
+
(0, import_errors.buildRunJsAuthoringError)({
|
|
60
|
+
path: input.path,
|
|
61
|
+
repairClass: "unknown-surface-stop",
|
|
62
|
+
message: `flowSurfaces authoring ${input.path} references unknown RunJS surface '${surface}'`,
|
|
63
|
+
modelUse,
|
|
64
|
+
surface,
|
|
65
|
+
index: 0,
|
|
66
|
+
source
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
return errors;
|
|
70
|
+
}
|
|
71
|
+
if (modelUse && !import_constants.KNOWN_MODEL_USES.has(modelUse)) {
|
|
72
|
+
errors.push(
|
|
73
|
+
(0, import_errors.buildRunJsAuthoringError)({
|
|
74
|
+
path: input.path,
|
|
75
|
+
repairClass: "unknown-model-stop",
|
|
76
|
+
message: `flowSurfaces authoring ${input.path} references unknown JS model '${modelUse}'`,
|
|
77
|
+
modelUse,
|
|
78
|
+
surface,
|
|
79
|
+
index: 0,
|
|
80
|
+
source
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
return errors;
|
|
84
|
+
}
|
|
85
|
+
if (surface && modelUse && import_constants.SURFACE_ALLOWED_MODEL_USES[surface] && !import_constants.SURFACE_ALLOWED_MODEL_USES[surface].has(modelUse)) {
|
|
86
|
+
errors.push(
|
|
87
|
+
(0, import_errors.buildRunJsAuthoringError)({
|
|
88
|
+
path: input.path,
|
|
89
|
+
repairClass: "unknown-model-stop",
|
|
90
|
+
message: `flowSurfaces authoring ${input.path} model '${modelUse}' is not supported by RunJS surface '${surface}'`,
|
|
91
|
+
modelUse,
|
|
92
|
+
surface,
|
|
93
|
+
index: 0,
|
|
94
|
+
source
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
return errors;
|
|
98
|
+
}
|
|
99
|
+
if (!surfaceStyle) {
|
|
100
|
+
errors.push(
|
|
101
|
+
(0, import_errors.buildRunJsAuthoringError)({
|
|
102
|
+
path: input.path,
|
|
103
|
+
repairClass: modelUse ? "unknown-model-stop" : "unknown-surface-stop",
|
|
104
|
+
message: `flowSurfaces authoring ${input.path} cannot resolve a RunJS validation surface`,
|
|
105
|
+
modelUse,
|
|
106
|
+
surface,
|
|
107
|
+
index: 0,
|
|
108
|
+
source
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
return errors;
|
|
112
|
+
}
|
|
113
|
+
const parseResult = (0, import_parser.parseRunJsAuthoringAst)(source);
|
|
114
|
+
if (parseResult.error) {
|
|
115
|
+
return [
|
|
116
|
+
(0, import_errors.buildRunJsAuthoringError)({
|
|
117
|
+
path: input.path,
|
|
118
|
+
repairClass: "syntax-stop",
|
|
119
|
+
ruleId: "runjs-syntax-invalid",
|
|
120
|
+
message: `flowSurfaces authoring ${input.path} has invalid JavaScript syntax: ${parseResult.error.message}`,
|
|
121
|
+
modelUse,
|
|
122
|
+
surface,
|
|
123
|
+
index: parseResult.error.index,
|
|
124
|
+
source,
|
|
125
|
+
details: {
|
|
126
|
+
syntaxMessage: parseResult.error.message
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
const scan = (0, import_scan.scanJavaScriptSource)(source, parseResult.ast, context, modelUse);
|
|
132
|
+
errors.push(
|
|
133
|
+
...(0, import_validators.collectRunJsInspectionErrors)({
|
|
134
|
+
context,
|
|
135
|
+
input,
|
|
136
|
+
modelUse,
|
|
137
|
+
scan,
|
|
138
|
+
source,
|
|
139
|
+
surface,
|
|
140
|
+
surfaceStyle
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
return (0, import_errors.dedupeErrors)(errors).slice(0, import_constants.MAX_RUNJS_ERRORS_PER_SOURCE);
|
|
144
|
+
}
|
|
145
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
146
|
+
0 && (module.exports = {
|
|
147
|
+
inspectRunJsAuthoringCode,
|
|
148
|
+
inspectRunJsAuthoringCodeForWrite
|
|
149
|
+
});
|
|
@@ -0,0 +1,333 @@
|
|
|
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 FlowSurfaceAuthoringWriteAction = 'applyBlueprint' | 'compose' | 'addBlock' | 'addBlocks' | 'configure';
|
|
10
|
+
export type RunJsAuthoringContext = {
|
|
11
|
+
authoringActionName?: FlowSurfaceAuthoringWriteAction;
|
|
12
|
+
applyBlueprintScriptAssets?: Record<string, any>;
|
|
13
|
+
currentCollectionName?: string;
|
|
14
|
+
currentDataSourceKey?: string;
|
|
15
|
+
currentNode?: any;
|
|
16
|
+
getCollection?: (dataSourceKey: string, collectionName: string) => any;
|
|
17
|
+
hostBlockType?: string;
|
|
18
|
+
hostCollectionName?: string;
|
|
19
|
+
hostDataSourceKey?: string;
|
|
20
|
+
runJsSourceBudget?: RunJsSourceBudget;
|
|
21
|
+
};
|
|
22
|
+
export type RunJsCodeSource = {
|
|
23
|
+
code: string;
|
|
24
|
+
path: string;
|
|
25
|
+
};
|
|
26
|
+
export type PlainRecord = Record<string, any>;
|
|
27
|
+
export type SourceRange = {
|
|
28
|
+
start: number;
|
|
29
|
+
end: number;
|
|
30
|
+
};
|
|
31
|
+
export type SourceBinding = SourceRange & {
|
|
32
|
+
declarationStart?: number;
|
|
33
|
+
executionScope?: SourceRange;
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
export type StringLiteralBinding = SourceBinding & {
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
export type StaticStringBinding = StringLiteralBinding;
|
|
40
|
+
export type StaticFilterValueBinding = SourceBinding & {
|
|
41
|
+
declarationStart: number;
|
|
42
|
+
executionScope: SourceRange;
|
|
43
|
+
valueNode: any;
|
|
44
|
+
};
|
|
45
|
+
export type AstIdentifierWrite = {
|
|
46
|
+
alwaysRunsInExecutionScope: boolean;
|
|
47
|
+
executionScope: SourceRange;
|
|
48
|
+
index: number;
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
export type AstStaticObjectAliasCopy = SourceRange & {
|
|
52
|
+
declarationStart: number;
|
|
53
|
+
executionScope: SourceRange;
|
|
54
|
+
name: string;
|
|
55
|
+
sourceName: string;
|
|
56
|
+
};
|
|
57
|
+
export type ReactComponentAlias = SourceRange & {
|
|
58
|
+
capability: string;
|
|
59
|
+
declarationStart?: number;
|
|
60
|
+
name: string;
|
|
61
|
+
};
|
|
62
|
+
export type ReactAsyncComponentBinding = SourceRange & {
|
|
63
|
+
capability: string;
|
|
64
|
+
component: string;
|
|
65
|
+
declarationStart?: number;
|
|
66
|
+
name: string;
|
|
67
|
+
};
|
|
68
|
+
export type ReactCreateElementAlias = SourceRange & {
|
|
69
|
+
capability: string;
|
|
70
|
+
declarationStart?: number;
|
|
71
|
+
name: string;
|
|
72
|
+
};
|
|
73
|
+
export type ReactNamespaceAlias = SourceRange & {
|
|
74
|
+
capability: string;
|
|
75
|
+
declarationStart?: number;
|
|
76
|
+
executionScope: SourceRange;
|
|
77
|
+
name: string;
|
|
78
|
+
precedenceStart?: number;
|
|
79
|
+
};
|
|
80
|
+
export type ReactDefaultAlias = SourceRange & {
|
|
81
|
+
capability: string;
|
|
82
|
+
declarationStart?: number;
|
|
83
|
+
executionScope: SourceRange;
|
|
84
|
+
name: string;
|
|
85
|
+
precedenceStart?: number;
|
|
86
|
+
};
|
|
87
|
+
export type AstCapabilityAlias = SourceRange & {
|
|
88
|
+
capability: string;
|
|
89
|
+
name: string;
|
|
90
|
+
precedenceStart?: number;
|
|
91
|
+
};
|
|
92
|
+
export declare const AST_DYNAMIC_MEMBER_ALIAS = "[*]";
|
|
93
|
+
export type InvalidReactRuntimeBinding = SourceRange & {
|
|
94
|
+
binding: string;
|
|
95
|
+
capability: string;
|
|
96
|
+
declarationStart?: number;
|
|
97
|
+
index: number;
|
|
98
|
+
ruleId: 'runjs-react-default-alias-forbidden';
|
|
99
|
+
};
|
|
100
|
+
export type FlowResourceAlias = SourceRange & {
|
|
101
|
+
capability: string;
|
|
102
|
+
declarationStart?: number;
|
|
103
|
+
name: string;
|
|
104
|
+
};
|
|
105
|
+
export type FlowResourceInstanceType = 'unknown' | 'FlowResource' | 'APIResource' | 'SingleRecordResource' | 'MultiRecordResource' | 'SQLResource';
|
|
106
|
+
export type AstFlowResourceAlias = SourceRange & {
|
|
107
|
+
capability: string;
|
|
108
|
+
declarationStart?: number;
|
|
109
|
+
executionScope: SourceRange;
|
|
110
|
+
name: string;
|
|
111
|
+
resourceType: FlowResourceInstanceType;
|
|
112
|
+
};
|
|
113
|
+
export type AstFlowResourceSource = {
|
|
114
|
+
capability: string;
|
|
115
|
+
index: number;
|
|
116
|
+
resourceType: FlowResourceInstanceType;
|
|
117
|
+
};
|
|
118
|
+
export type AstRunJsResourceState = {
|
|
119
|
+
capability: string;
|
|
120
|
+
collectionName?: string;
|
|
121
|
+
dataSourceKey: string;
|
|
122
|
+
resourceType: FlowResourceInstanceType;
|
|
123
|
+
};
|
|
124
|
+
export type CtxLibMemberCaseMismatch = {
|
|
125
|
+
accessKind: 'bracket' | 'destructure' | 'member';
|
|
126
|
+
capability: string;
|
|
127
|
+
expectedCapability: string;
|
|
128
|
+
expectedMember: string;
|
|
129
|
+
index: number;
|
|
130
|
+
member: string;
|
|
131
|
+
};
|
|
132
|
+
export type InvalidCtxLibMemberAccess = {
|
|
133
|
+
accessKind: 'bracket' | 'destructure' | 'member';
|
|
134
|
+
capability: string;
|
|
135
|
+
index: number;
|
|
136
|
+
library: string;
|
|
137
|
+
member: string;
|
|
138
|
+
ruleId: 'runjs-ctx-libs-member-unknown';
|
|
139
|
+
suggestedImport?: string;
|
|
140
|
+
};
|
|
141
|
+
export type CallArgumentSource = SourceRange & {
|
|
142
|
+
source: string;
|
|
143
|
+
};
|
|
144
|
+
export type ResourceCallInReactHook = {
|
|
145
|
+
capability: string;
|
|
146
|
+
hook: string;
|
|
147
|
+
index: number;
|
|
148
|
+
};
|
|
149
|
+
export type SharedCtxResourceCallInFunction = {
|
|
150
|
+
capability: string;
|
|
151
|
+
functionName?: string;
|
|
152
|
+
index: number;
|
|
153
|
+
};
|
|
154
|
+
export type RunJsSourceBudget = {
|
|
155
|
+
count: number;
|
|
156
|
+
countLimitReported?: boolean;
|
|
157
|
+
totalLength: number;
|
|
158
|
+
totalLimitReported?: boolean;
|
|
159
|
+
};
|
|
160
|
+
export type RunJsAstInspection = {
|
|
161
|
+
unknownBareGlobals: Array<{
|
|
162
|
+
index: number;
|
|
163
|
+
name: string;
|
|
164
|
+
suggestedCapability?: string;
|
|
165
|
+
}>;
|
|
166
|
+
invalidApiResourceCalls: Array<{
|
|
167
|
+
index: number;
|
|
168
|
+
match: string;
|
|
169
|
+
matchIndex?: number;
|
|
170
|
+
method: string;
|
|
171
|
+
}>;
|
|
172
|
+
invalidResourceActionCalls: Array<{
|
|
173
|
+
actionName: string;
|
|
174
|
+
allowedActions?: string[];
|
|
175
|
+
capability: string;
|
|
176
|
+
collectionName?: string;
|
|
177
|
+
dataSourceKey?: string;
|
|
178
|
+
endpoint?: string;
|
|
179
|
+
index: number;
|
|
180
|
+
invalidReason: string;
|
|
181
|
+
resourceType?: FlowResourceInstanceType;
|
|
182
|
+
suggestedMethod?: string;
|
|
183
|
+
}>;
|
|
184
|
+
invalidCtxApiMemberAccesses: Array<{
|
|
185
|
+
capability: string;
|
|
186
|
+
index: number;
|
|
187
|
+
match?: string;
|
|
188
|
+
matchIndex?: number;
|
|
189
|
+
member?: string;
|
|
190
|
+
ruleId: string;
|
|
191
|
+
}>;
|
|
192
|
+
invalidCtxNonFunctionCalls: Array<{
|
|
193
|
+
capability: string;
|
|
194
|
+
index: number;
|
|
195
|
+
member: string;
|
|
196
|
+
ruleId: 'runjs-ctx-member-not-callable';
|
|
197
|
+
}>;
|
|
198
|
+
invalidCtxLibMemberAccesses: InvalidCtxLibMemberAccess[];
|
|
199
|
+
invalidResourceTypeCalls: Array<{
|
|
200
|
+
capability: string;
|
|
201
|
+
expression?: string;
|
|
202
|
+
index: number;
|
|
203
|
+
resourceType?: string;
|
|
204
|
+
ruleId: string;
|
|
205
|
+
}>;
|
|
206
|
+
invalidFlowResourceListCalls: Array<{
|
|
207
|
+
capability: string;
|
|
208
|
+
index: number;
|
|
209
|
+
}>;
|
|
210
|
+
invalidFlowResourceMethodCalls: Array<{
|
|
211
|
+
capability: string;
|
|
212
|
+
index: number;
|
|
213
|
+
method: string;
|
|
214
|
+
resourceType?: FlowResourceInstanceType;
|
|
215
|
+
suggestedMethod?: string;
|
|
216
|
+
}>;
|
|
217
|
+
invalidResourceFilterCalls: Array<{
|
|
218
|
+
availableFields?: string[];
|
|
219
|
+
capability: string;
|
|
220
|
+
collectionName?: string;
|
|
221
|
+
dataSourceKey?: string;
|
|
222
|
+
fieldInterface?: string;
|
|
223
|
+
fieldPath?: string;
|
|
224
|
+
fieldType?: string;
|
|
225
|
+
invalidShape?: string;
|
|
226
|
+
index: number;
|
|
227
|
+
invalidReason?: string;
|
|
228
|
+
invalidValue?: any;
|
|
229
|
+
message: string;
|
|
230
|
+
operator?: string;
|
|
231
|
+
repairExample?: Record<string, any>;
|
|
232
|
+
repairHint?: string;
|
|
233
|
+
resourceType?: FlowResourceInstanceType;
|
|
234
|
+
ruleId: string;
|
|
235
|
+
unsupportedKeys?: string[];
|
|
236
|
+
suggestedOperator?: string;
|
|
237
|
+
suggestedValue?: any;
|
|
238
|
+
examples?: Record<string, any>;
|
|
239
|
+
}>;
|
|
240
|
+
nestedRunjsCalls: Array<{
|
|
241
|
+
capability: string;
|
|
242
|
+
index: number;
|
|
243
|
+
}>;
|
|
244
|
+
invalidReactRuntimeBindings: InvalidReactRuntimeBinding[];
|
|
245
|
+
reactAsyncComponentReferences: Array<{
|
|
246
|
+
capability: string;
|
|
247
|
+
component: string;
|
|
248
|
+
index: number;
|
|
249
|
+
}>;
|
|
250
|
+
reactComponentCtxRenderCalls: Array<{
|
|
251
|
+
capability: string;
|
|
252
|
+
component: string;
|
|
253
|
+
index: number;
|
|
254
|
+
}>;
|
|
255
|
+
sharedCtxResourceCallsInFunctions: SharedCtxResourceCallInFunction[];
|
|
256
|
+
topLevelReachableCtxRenderCalls: Array<{
|
|
257
|
+
capability: string;
|
|
258
|
+
index: number;
|
|
259
|
+
}>;
|
|
260
|
+
};
|
|
261
|
+
export type CtxMethodAlias = SourceRange & {
|
|
262
|
+
capability: string;
|
|
263
|
+
method: string;
|
|
264
|
+
name: string;
|
|
265
|
+
};
|
|
266
|
+
export type CtxRootAlias = SourceRange & {
|
|
267
|
+
capability: 'ctx';
|
|
268
|
+
declarationStart?: number;
|
|
269
|
+
executionScope: SourceRange;
|
|
270
|
+
name: string;
|
|
271
|
+
};
|
|
272
|
+
export type CtxNonFunctionRootAlias = SourceRange & {
|
|
273
|
+
capability: string;
|
|
274
|
+
declarationStart?: number;
|
|
275
|
+
executionScope: SourceRange;
|
|
276
|
+
member: string;
|
|
277
|
+
name: string;
|
|
278
|
+
};
|
|
279
|
+
export type CtxLibsRootAlias = SourceRange & {
|
|
280
|
+
capability: 'ctx.libs';
|
|
281
|
+
declarationStart?: number;
|
|
282
|
+
executionScope: SourceRange;
|
|
283
|
+
name: string;
|
|
284
|
+
};
|
|
285
|
+
export type CtxLibAlias = SourceRange & {
|
|
286
|
+
capability: string;
|
|
287
|
+
declarationStart?: number;
|
|
288
|
+
executionScope: SourceRange;
|
|
289
|
+
library: string;
|
|
290
|
+
name: string;
|
|
291
|
+
};
|
|
292
|
+
export type CtxApiCapability = 'ctx.api' | 'ctx.api.auth' | 'ctx.api.request' | 'ctx.api.resource' | `ctx.api.auth.${string}`;
|
|
293
|
+
export type CtxApiAlias = SourceRange & {
|
|
294
|
+
capability: CtxApiCapability;
|
|
295
|
+
declarationStart?: number;
|
|
296
|
+
executionScope: SourceRange;
|
|
297
|
+
name: string;
|
|
298
|
+
};
|
|
299
|
+
export type CtxApiResourceHandleAlias = SourceRange & {
|
|
300
|
+
calleeSource: string;
|
|
301
|
+
dataSourceKey?: string;
|
|
302
|
+
declarationStart?: number;
|
|
303
|
+
executionScope: SourceRange;
|
|
304
|
+
name: string;
|
|
305
|
+
resourceName?: string;
|
|
306
|
+
};
|
|
307
|
+
export type CtxApiResourceMethodAlias = SourceRange & {
|
|
308
|
+
declarationStart?: number;
|
|
309
|
+
executionScope: SourceRange;
|
|
310
|
+
method: string;
|
|
311
|
+
name: string;
|
|
312
|
+
};
|
|
313
|
+
export type CtxApiResourceAliases = {
|
|
314
|
+
handles: CtxApiResourceHandleAlias[];
|
|
315
|
+
methods: CtxApiResourceMethodAlias[];
|
|
316
|
+
};
|
|
317
|
+
export type AstIdentifierBinding = SourceRange & {
|
|
318
|
+
declarationStart?: number;
|
|
319
|
+
name: string;
|
|
320
|
+
unavailableRanges?: SourceRange[];
|
|
321
|
+
};
|
|
322
|
+
export type AstFunctionBinding = SourceRange & {
|
|
323
|
+
declarationStart: number;
|
|
324
|
+
functionNode: any;
|
|
325
|
+
hoisted: boolean;
|
|
326
|
+
name: string;
|
|
327
|
+
scopeStart: number;
|
|
328
|
+
};
|
|
329
|
+
export type AstCtxRenderCall = {
|
|
330
|
+
args: any[];
|
|
331
|
+
capability: string;
|
|
332
|
+
index: number;
|
|
333
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 internal_types_exports = {};
|
|
28
|
+
__export(internal_types_exports, {
|
|
29
|
+
AST_DYNAMIC_MEMBER_ALIAS: () => AST_DYNAMIC_MEMBER_ALIAS
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(internal_types_exports);
|
|
32
|
+
const AST_DYNAMIC_MEMBER_ALIAS = "[*]";
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
AST_DYNAMIC_MEMBER_ALIAS
|
|
36
|
+
});
|
|
@@ -45,6 +45,7 @@ var import_resource_runtime_contract_stop = require("./resource-runtime-contract
|
|
|
45
45
|
var import_source_limit_stop = require("./source-limit-stop");
|
|
46
46
|
var import_switch_to_resource_api = require("./switch-to-resource-api");
|
|
47
47
|
var import_syntax_stop = require("./syntax-stop");
|
|
48
|
+
var import_unknown_global_stop = require("./unknown-global-stop");
|
|
48
49
|
var import_unknown_model_stop = require("./unknown-model-stop");
|
|
49
50
|
var import_unknown_surface_stop = require("./unknown-surface-stop");
|
|
50
51
|
var import_value_surface_forbids_render = require("./value-surface-forbids-render");
|
|
@@ -61,6 +62,7 @@ const RUNJS_AUTHORING_RULES = [
|
|
|
61
62
|
import_render_top_level_function_wrapper.renderTopLevelFunctionWrapperRule,
|
|
62
63
|
import_render_unreachable_render_call.renderUnreachableRenderCallRule,
|
|
63
64
|
import_blocked_global_stop.blockedGlobalStopRule,
|
|
65
|
+
import_unknown_global_stop.unknownGlobalStopRule,
|
|
64
66
|
import_blocked_capability_reroute.blockedCapabilityRerouteRule,
|
|
65
67
|
import_react_runtime_contract_stop.reactRuntimeContractStopRule,
|
|
66
68
|
import_resource_runtime_contract_stop.resourceRuntimeContractStopRule,
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { FlowResourceInstanceType } from '../internal-types';
|
|
10
|
+
import type { RunJsAuthoringRepairClass, RunJsAuthoringSurfaceStyle } from '../types';
|
|
11
|
+
export declare const RENDER_MODEL_USES: Set<string>;
|
|
12
|
+
export declare const ACTION_MODEL_USES: Set<string>;
|
|
13
|
+
export declare const VALUE_MODEL_USES: Set<string>;
|
|
14
|
+
export declare const KNOWN_MODEL_USES: Set<string>;
|
|
15
|
+
export declare const PUBLIC_BLOCK_TYPE_BY_MODEL_USE: Record<string, string>;
|
|
16
|
+
export declare const SURFACE_STYLE_BY_ID: Record<string, RunJsAuthoringSurfaceStyle>;
|
|
17
|
+
export declare const SURFACE_ALLOWED_MODEL_USES: Record<string, Set<string>>;
|
|
18
|
+
export declare const ALLOWED_CTX_ROOTS: Set<string>;
|
|
19
|
+
export declare const CHART_CTX_ROOTS: Set<string>;
|
|
20
|
+
export declare const BLOCKED_CTX_CAPABILITIES: Record<string, {
|
|
21
|
+
capability: string;
|
|
22
|
+
reroute: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const FORBIDDEN_BARE_GLOBALS: Set<string>;
|
|
25
|
+
export declare const RUNJS_ALLOWED_BARE_GLOBALS: Set<string>;
|
|
26
|
+
export declare const RUNJS_ALLOWED_BARE_GLOBALS_BY_MODEL_USE: Record<string, Set<string>>;
|
|
27
|
+
export declare const NON_METHOD_CALL_KEYWORDS: Set<string>;
|
|
28
|
+
export declare const ACTION_TYPE_ALIASES: Map<string, string>;
|
|
29
|
+
export declare const REACT_HOOK_NAMES: string[];
|
|
30
|
+
export declare const REACT_HOOK_PATTERN: string;
|
|
31
|
+
export declare const RUNJS_RESOURCE_ACTION_PATTERN = "(?:list|get|create|update|destroy)";
|
|
32
|
+
export declare const MAX_RUNJS_SOURCE_LENGTH: number;
|
|
33
|
+
export declare const MAX_RUNJS_TOTAL_SOURCE_LENGTH: number;
|
|
34
|
+
export declare const MAX_RUNJS_SOURCES_PER_REQUEST = 100;
|
|
35
|
+
export declare const MAX_RUNJS_ERRORS_PER_SOURCE = 20;
|
|
36
|
+
export declare const RUNJS_SUPPORTED_FILTER_OPERATORS: Set<string>;
|
|
37
|
+
export declare const RUNJS_DATE_FILTER_OPERATORS: Set<string>;
|
|
38
|
+
export declare const RUNJS_UNSUPPORTED_DATE_RANGE_VALUE_KEYS: Set<string>;
|
|
39
|
+
export declare const FLOW_RESOURCE_CLASS_NAMES: Set<string>;
|
|
40
|
+
export declare const INIT_RESOURCE_CLASS_NAMES: Set<string>;
|
|
41
|
+
export declare const AST_CTX_METHOD_NAMES: Set<string>;
|
|
42
|
+
export declare const RUNJS_CTX_NON_FUNCTION_ROOTS: Set<string>;
|
|
43
|
+
export declare const RUNJS_CTX_NON_FUNCTION_ROOTS_BY_MODEL_USE: Record<string, Set<string>>;
|
|
44
|
+
export declare const REACT_NODE_COMPONENT_PROP_NAMES: Set<string>;
|
|
45
|
+
export declare const CANONICAL_CTX_LIB_MEMBERS: string[];
|
|
46
|
+
export declare const CTX_LIB_MEMBER_BY_LOWERCASE: Map<string, string>;
|
|
47
|
+
export declare const RUNJS_CTX_LIB_ANTD_ALLOWED_MEMBERS: Set<string>;
|
|
48
|
+
export declare const RUNJS_CTX_LIB_ALLOWED_MEMBERS_BY_LIBRARY: Map<string, Set<string>>;
|
|
49
|
+
export declare const RUNJS_CTX_API_ALLOWED_MEMBERS: Set<string>;
|
|
50
|
+
export declare const RUNJS_CTX_API_AUTH_ALLOWED_MEMBERS: Set<string>;
|
|
51
|
+
export declare const RUNJS_RESOURCE_METHODS: Set<string>;
|
|
52
|
+
export declare const RUNJS_COLLECTION_RESOURCE_ACTIONS: Set<string>;
|
|
53
|
+
export declare const RUNJS_COLLECTION_RESOURCE_ACTION_ALIASES: Map<string, string[]>;
|
|
54
|
+
export declare const RUNJS_RESOURCE_ENDPOINT_ACTION_PATTERN = "[A-Za-z_$][\\w$-]*";
|
|
55
|
+
export declare const FLOW_RESOURCE_BASE_METHODS: Set<string>;
|
|
56
|
+
export declare const API_RESOURCE_METHODS: Set<string>;
|
|
57
|
+
export declare const RECORD_RESOURCE_METHODS: Set<string>;
|
|
58
|
+
export declare const RUNJS_RESOURCE_CHAINABLE_STATE_METHODS: Set<string>;
|
|
59
|
+
export declare const MULTI_RECORD_RESOURCE_METHODS: Set<string>;
|
|
60
|
+
export declare const SINGLE_RECORD_RESOURCE_METHODS: Set<string>;
|
|
61
|
+
export declare const SQL_RESOURCE_METHODS: Set<string>;
|
|
62
|
+
export declare const FLOW_RESOURCE_METHODS_BY_TYPE: Record<Exclude<FlowResourceInstanceType, 'unknown'>, Set<string>>;
|
|
63
|
+
export declare const UNKNOWN_FLOW_RESOURCE_METHODS: Set<string>;
|
|
64
|
+
export declare const FLOW_RESOURCE_METHOD_SUGGESTIONS: Map<string, string>;
|
|
65
|
+
export declare const CONTEXT_FIRST_REPAIR_CLASSES: Set<RunJsAuthoringRepairClass>;
|
|
66
|
+
export declare const RUNJS_FIX_AND_RETRY_INSTRUCTION = "Do not skip this JS/RunJS step. Fix the error and retry the same write. If the response contains errors[], fix every listed error in one payload revision before retrying. Do not remove, defer, or replace the JS/RunJS capability to bypass validation.";
|
|
67
|
+
export declare const RUNJS_CONTEXT_AND_RETRY_INSTRUCTION = "Do not skip this JS/RunJS step. Resolve the blocking context/problem first, then retry the same write. If the response contains errors[], fix every listed error in one payload revision before retrying. Do not remove, defer, or replace the JS/RunJS capability to bypass validation.";
|