@octaviaflow/flow-rules 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +159 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +159 -0
- package/dist/rules/configSafety.d.ts +62 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -53,6 +53,7 @@ __export(exports_src, {
|
|
|
53
53
|
ForEachConfig: () => ForEachConfig,
|
|
54
54
|
JoinType: () => JoinType,
|
|
55
55
|
LogicalOperator: () => LogicalOperator,
|
|
56
|
+
MAX_STEP_CONFIG_BYTES: () => MAX_STEP_CONFIG_BYTES,
|
|
56
57
|
ManualTriggerConfig: () => ManualTriggerConfig,
|
|
57
58
|
NodeStatus: () => NodeStatus,
|
|
58
59
|
QueryMode: () => QueryMode,
|
|
@@ -66,6 +67,7 @@ __export(exports_src, {
|
|
|
66
67
|
buildPathOptions: () => buildPathOptions,
|
|
67
68
|
collectArrayPaths: () => collectArrayPaths,
|
|
68
69
|
collectArrayPathsFromSample: () => collectArrayPathsFromSample,
|
|
70
|
+
configErrors: () => configErrors,
|
|
69
71
|
emailDefinition: () => emailDefinition,
|
|
70
72
|
flattenNestedWorkflow: () => flattenNestedWorkflow,
|
|
71
73
|
generateConnectionsFromSteps: () => generateConnectionsFromSteps,
|
|
@@ -91,6 +93,8 @@ __export(exports_src, {
|
|
|
91
93
|
validateEdge: () => validateEdge,
|
|
92
94
|
validateFlowData: () => validateFlowData,
|
|
93
95
|
validateNode: () => validateNode,
|
|
96
|
+
validateStepConfig: () => validateStepConfig,
|
|
97
|
+
validateStepConfigs: () => validateStepConfigs,
|
|
94
98
|
validateWorkflow: () => validateWorkflow
|
|
95
99
|
});
|
|
96
100
|
module.exports = __toCommonJS(exports_src);
|
|
@@ -4093,3 +4097,158 @@ function validateFlowData(flow) {
|
|
|
4093
4097
|
const f = flow;
|
|
4094
4098
|
return typeof f.id === "string" && typeof f.name === "string" && f.workflow !== undefined && typeof f.workflow === "object" && f.workflow !== null && Array.isArray(f.workflow.steps);
|
|
4095
4099
|
}
|
|
4100
|
+
// src/rules/configSafety.ts
|
|
4101
|
+
var MAX_STEP_CONFIG_BYTES = 256 * 1024;
|
|
4102
|
+
var FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
4103
|
+
var MAX_DEPTH = 12;
|
|
4104
|
+
function typeMatches(field, value) {
|
|
4105
|
+
if (value === null || value === undefined || value === "")
|
|
4106
|
+
return true;
|
|
4107
|
+
switch (field.type) {
|
|
4108
|
+
case "number" /* Number */:
|
|
4109
|
+
return typeof value === "number" || typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value));
|
|
4110
|
+
case "boolean" /* Boolean */:
|
|
4111
|
+
return typeof value === "boolean" || value === "true" || value === "false";
|
|
4112
|
+
case "array" /* Array */:
|
|
4113
|
+
case "multi_select" /* MultiSelect */:
|
|
4114
|
+
return Array.isArray(value);
|
|
4115
|
+
case "object" /* Object */:
|
|
4116
|
+
case "mapping" /* Mapping */:
|
|
4117
|
+
return typeof value === "object" && !Array.isArray(value);
|
|
4118
|
+
case "string" /* String */:
|
|
4119
|
+
case "code" /* Code */:
|
|
4120
|
+
case "expression" /* Expression */:
|
|
4121
|
+
case "select" /* Select */:
|
|
4122
|
+
case "connection" /* Connection */:
|
|
4123
|
+
case "secret" /* Secret */:
|
|
4124
|
+
case "url" /* URL */:
|
|
4125
|
+
case "email" /* Email */:
|
|
4126
|
+
case "phone" /* Phone */:
|
|
4127
|
+
case "color" /* Color */:
|
|
4128
|
+
case "rich_text" /* RichText */:
|
|
4129
|
+
case "markdown" /* Markdown */:
|
|
4130
|
+
case "date" /* Date */:
|
|
4131
|
+
case "datetime" /* DateTime */:
|
|
4132
|
+
return typeof value !== "object";
|
|
4133
|
+
default:
|
|
4134
|
+
return true;
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
function walk(value, stepId, path, depth, issues) {
|
|
4138
|
+
if (depth > MAX_DEPTH) {
|
|
4139
|
+
issues.push({
|
|
4140
|
+
severity: "error",
|
|
4141
|
+
code: "CONFIG_TOO_DEEP",
|
|
4142
|
+
stepId,
|
|
4143
|
+
field: path || undefined,
|
|
4144
|
+
message: `Configuration nests deeper than ${MAX_DEPTH} levels.`
|
|
4145
|
+
});
|
|
4146
|
+
return;
|
|
4147
|
+
}
|
|
4148
|
+
if (Array.isArray(value)) {
|
|
4149
|
+
for (const item of value)
|
|
4150
|
+
walk(item, stepId, path, depth + 1, issues);
|
|
4151
|
+
return;
|
|
4152
|
+
}
|
|
4153
|
+
if (value === null || typeof value !== "object")
|
|
4154
|
+
return;
|
|
4155
|
+
for (const key of Object.keys(value)) {
|
|
4156
|
+
if (FORBIDDEN_KEYS.has(key)) {
|
|
4157
|
+
issues.push({
|
|
4158
|
+
severity: "error",
|
|
4159
|
+
code: "FORBIDDEN_KEY",
|
|
4160
|
+
stepId,
|
|
4161
|
+
field: path ? `${path}.${key}` : key,
|
|
4162
|
+
message: `\`${key}\` is not allowed in a step's configuration.`
|
|
4163
|
+
});
|
|
4164
|
+
continue;
|
|
4165
|
+
}
|
|
4166
|
+
walk(value[key], stepId, path ? `${path}.${key}` : key, depth + 1, issues);
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
function validateStepConfig(step) {
|
|
4170
|
+
const issues = [];
|
|
4171
|
+
const stepId = typeof step.id === "string" ? step.id : "(unknown step)";
|
|
4172
|
+
const config = step.config;
|
|
4173
|
+
if (config === null || config === undefined)
|
|
4174
|
+
return issues;
|
|
4175
|
+
if (typeof config !== "object" || Array.isArray(config)) {
|
|
4176
|
+
issues.push({
|
|
4177
|
+
severity: "error",
|
|
4178
|
+
code: "FIELD_WRONG_TYPE",
|
|
4179
|
+
stepId,
|
|
4180
|
+
message: "A step's configuration must be an object."
|
|
4181
|
+
});
|
|
4182
|
+
return issues;
|
|
4183
|
+
}
|
|
4184
|
+
let serialised;
|
|
4185
|
+
try {
|
|
4186
|
+
serialised = JSON.stringify(config);
|
|
4187
|
+
} catch {
|
|
4188
|
+
issues.push({
|
|
4189
|
+
severity: "error",
|
|
4190
|
+
code: "FIELD_WRONG_TYPE",
|
|
4191
|
+
stepId,
|
|
4192
|
+
message: "A step's configuration must be plain JSON."
|
|
4193
|
+
});
|
|
4194
|
+
return issues;
|
|
4195
|
+
}
|
|
4196
|
+
if (serialised.length > MAX_STEP_CONFIG_BYTES) {
|
|
4197
|
+
issues.push({
|
|
4198
|
+
severity: "error",
|
|
4199
|
+
code: "CONFIG_TOO_LARGE",
|
|
4200
|
+
stepId,
|
|
4201
|
+
message: `Configuration is ${Math.round(serialised.length / 1024)} KB; the limit is ${MAX_STEP_CONFIG_BYTES / 1024} KB.`
|
|
4202
|
+
});
|
|
4203
|
+
}
|
|
4204
|
+
walk(config, stepId, "", 0, issues);
|
|
4205
|
+
const definition = typeof step.actionDefinitionId === "string" ? getActionById(step.actionDefinitionId) : undefined;
|
|
4206
|
+
if (!definition)
|
|
4207
|
+
return issues;
|
|
4208
|
+
const declared = new Map(definition.inputSchema.fields.map((f) => [f.key, f]));
|
|
4209
|
+
const entries = Object.entries(config);
|
|
4210
|
+
for (const [key, value] of entries) {
|
|
4211
|
+
const field = declared.get(key);
|
|
4212
|
+
if (!field) {
|
|
4213
|
+
issues.push({
|
|
4214
|
+
severity: "warning",
|
|
4215
|
+
code: "UNDECLARED_FIELD",
|
|
4216
|
+
stepId,
|
|
4217
|
+
field: key,
|
|
4218
|
+
message: `\`${key}\` is not declared by ${definition.id}.`
|
|
4219
|
+
});
|
|
4220
|
+
continue;
|
|
4221
|
+
}
|
|
4222
|
+
if (!typeMatches(field, value)) {
|
|
4223
|
+
issues.push({
|
|
4224
|
+
severity: "error",
|
|
4225
|
+
code: "FIELD_WRONG_TYPE",
|
|
4226
|
+
stepId,
|
|
4227
|
+
field: key,
|
|
4228
|
+
message: `\`${key}\` must be ${field.type}.`
|
|
4229
|
+
});
|
|
4230
|
+
continue;
|
|
4231
|
+
}
|
|
4232
|
+
if (field.options && field.options.length > 0 && value !== null && value !== undefined && value !== "") {
|
|
4233
|
+
const allowed = new Set(field.options.map((o) => o.value));
|
|
4234
|
+
const values = Array.isArray(value) ? value : [value];
|
|
4235
|
+
const bad = values.filter((v) => (typeof v === "string" || typeof v === "number") && !allowed.has(v));
|
|
4236
|
+
if (bad.length > 0) {
|
|
4237
|
+
issues.push({
|
|
4238
|
+
severity: "warning",
|
|
4239
|
+
code: "FIELD_BAD_OPTION",
|
|
4240
|
+
stepId,
|
|
4241
|
+
field: key,
|
|
4242
|
+
message: `\`${key}\` must be one of: ${[...allowed].join(", ")}.`
|
|
4243
|
+
});
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
}
|
|
4247
|
+
return issues;
|
|
4248
|
+
}
|
|
4249
|
+
function validateStepConfigs(steps) {
|
|
4250
|
+
return steps.flatMap((s) => validateStepConfig(s));
|
|
4251
|
+
}
|
|
4252
|
+
function configErrors(steps) {
|
|
4253
|
+
return validateStepConfigs(steps).filter((i) => i.severity === "error");
|
|
4254
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -43,3 +43,4 @@ export { type ManualTriggerConfigType } from "./catalog/triggers/manual-trigger/
|
|
|
43
43
|
export * from "./catalog/workflow";
|
|
44
44
|
export { type FlowConnection, type FlowData, type FlowStep, generateConnectionsFromSteps, transformConnectionToEdge, transformFlowToWorkflow, transformStepToNode, validateFlowData, } from "./rules/flowShape";
|
|
45
45
|
export { flattenNestedWorkflow } from "./rules/flattenNestedWorkflow";
|
|
46
|
+
export { configErrors, MAX_STEP_CONFIG_BYTES, validateStepConfig, validateStepConfigs, type ConfigIssue, type ConfigIssueCode, } from "./rules/configSafety";
|
package/dist/index.js
CHANGED
|
@@ -3996,6 +3996,161 @@ function validateFlowData(flow) {
|
|
|
3996
3996
|
const f = flow;
|
|
3997
3997
|
return typeof f.id === "string" && typeof f.name === "string" && f.workflow !== undefined && typeof f.workflow === "object" && f.workflow !== null && Array.isArray(f.workflow.steps);
|
|
3998
3998
|
}
|
|
3999
|
+
// src/rules/configSafety.ts
|
|
4000
|
+
var MAX_STEP_CONFIG_BYTES = 256 * 1024;
|
|
4001
|
+
var FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
4002
|
+
var MAX_DEPTH = 12;
|
|
4003
|
+
function typeMatches(field, value) {
|
|
4004
|
+
if (value === null || value === undefined || value === "")
|
|
4005
|
+
return true;
|
|
4006
|
+
switch (field.type) {
|
|
4007
|
+
case "number" /* Number */:
|
|
4008
|
+
return typeof value === "number" || typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value));
|
|
4009
|
+
case "boolean" /* Boolean */:
|
|
4010
|
+
return typeof value === "boolean" || value === "true" || value === "false";
|
|
4011
|
+
case "array" /* Array */:
|
|
4012
|
+
case "multi_select" /* MultiSelect */:
|
|
4013
|
+
return Array.isArray(value);
|
|
4014
|
+
case "object" /* Object */:
|
|
4015
|
+
case "mapping" /* Mapping */:
|
|
4016
|
+
return typeof value === "object" && !Array.isArray(value);
|
|
4017
|
+
case "string" /* String */:
|
|
4018
|
+
case "code" /* Code */:
|
|
4019
|
+
case "expression" /* Expression */:
|
|
4020
|
+
case "select" /* Select */:
|
|
4021
|
+
case "connection" /* Connection */:
|
|
4022
|
+
case "secret" /* Secret */:
|
|
4023
|
+
case "url" /* URL */:
|
|
4024
|
+
case "email" /* Email */:
|
|
4025
|
+
case "phone" /* Phone */:
|
|
4026
|
+
case "color" /* Color */:
|
|
4027
|
+
case "rich_text" /* RichText */:
|
|
4028
|
+
case "markdown" /* Markdown */:
|
|
4029
|
+
case "date" /* Date */:
|
|
4030
|
+
case "datetime" /* DateTime */:
|
|
4031
|
+
return typeof value !== "object";
|
|
4032
|
+
default:
|
|
4033
|
+
return true;
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
function walk(value, stepId, path, depth, issues) {
|
|
4037
|
+
if (depth > MAX_DEPTH) {
|
|
4038
|
+
issues.push({
|
|
4039
|
+
severity: "error",
|
|
4040
|
+
code: "CONFIG_TOO_DEEP",
|
|
4041
|
+
stepId,
|
|
4042
|
+
field: path || undefined,
|
|
4043
|
+
message: `Configuration nests deeper than ${MAX_DEPTH} levels.`
|
|
4044
|
+
});
|
|
4045
|
+
return;
|
|
4046
|
+
}
|
|
4047
|
+
if (Array.isArray(value)) {
|
|
4048
|
+
for (const item of value)
|
|
4049
|
+
walk(item, stepId, path, depth + 1, issues);
|
|
4050
|
+
return;
|
|
4051
|
+
}
|
|
4052
|
+
if (value === null || typeof value !== "object")
|
|
4053
|
+
return;
|
|
4054
|
+
for (const key of Object.keys(value)) {
|
|
4055
|
+
if (FORBIDDEN_KEYS.has(key)) {
|
|
4056
|
+
issues.push({
|
|
4057
|
+
severity: "error",
|
|
4058
|
+
code: "FORBIDDEN_KEY",
|
|
4059
|
+
stepId,
|
|
4060
|
+
field: path ? `${path}.${key}` : key,
|
|
4061
|
+
message: `\`${key}\` is not allowed in a step's configuration.`
|
|
4062
|
+
});
|
|
4063
|
+
continue;
|
|
4064
|
+
}
|
|
4065
|
+
walk(value[key], stepId, path ? `${path}.${key}` : key, depth + 1, issues);
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
function validateStepConfig(step) {
|
|
4069
|
+
const issues = [];
|
|
4070
|
+
const stepId = typeof step.id === "string" ? step.id : "(unknown step)";
|
|
4071
|
+
const config = step.config;
|
|
4072
|
+
if (config === null || config === undefined)
|
|
4073
|
+
return issues;
|
|
4074
|
+
if (typeof config !== "object" || Array.isArray(config)) {
|
|
4075
|
+
issues.push({
|
|
4076
|
+
severity: "error",
|
|
4077
|
+
code: "FIELD_WRONG_TYPE",
|
|
4078
|
+
stepId,
|
|
4079
|
+
message: "A step's configuration must be an object."
|
|
4080
|
+
});
|
|
4081
|
+
return issues;
|
|
4082
|
+
}
|
|
4083
|
+
let serialised;
|
|
4084
|
+
try {
|
|
4085
|
+
serialised = JSON.stringify(config);
|
|
4086
|
+
} catch {
|
|
4087
|
+
issues.push({
|
|
4088
|
+
severity: "error",
|
|
4089
|
+
code: "FIELD_WRONG_TYPE",
|
|
4090
|
+
stepId,
|
|
4091
|
+
message: "A step's configuration must be plain JSON."
|
|
4092
|
+
});
|
|
4093
|
+
return issues;
|
|
4094
|
+
}
|
|
4095
|
+
if (serialised.length > MAX_STEP_CONFIG_BYTES) {
|
|
4096
|
+
issues.push({
|
|
4097
|
+
severity: "error",
|
|
4098
|
+
code: "CONFIG_TOO_LARGE",
|
|
4099
|
+
stepId,
|
|
4100
|
+
message: `Configuration is ${Math.round(serialised.length / 1024)} KB; the limit is ${MAX_STEP_CONFIG_BYTES / 1024} KB.`
|
|
4101
|
+
});
|
|
4102
|
+
}
|
|
4103
|
+
walk(config, stepId, "", 0, issues);
|
|
4104
|
+
const definition = typeof step.actionDefinitionId === "string" ? getActionById(step.actionDefinitionId) : undefined;
|
|
4105
|
+
if (!definition)
|
|
4106
|
+
return issues;
|
|
4107
|
+
const declared = new Map(definition.inputSchema.fields.map((f) => [f.key, f]));
|
|
4108
|
+
const entries = Object.entries(config);
|
|
4109
|
+
for (const [key, value] of entries) {
|
|
4110
|
+
const field = declared.get(key);
|
|
4111
|
+
if (!field) {
|
|
4112
|
+
issues.push({
|
|
4113
|
+
severity: "warning",
|
|
4114
|
+
code: "UNDECLARED_FIELD",
|
|
4115
|
+
stepId,
|
|
4116
|
+
field: key,
|
|
4117
|
+
message: `\`${key}\` is not declared by ${definition.id}.`
|
|
4118
|
+
});
|
|
4119
|
+
continue;
|
|
4120
|
+
}
|
|
4121
|
+
if (!typeMatches(field, value)) {
|
|
4122
|
+
issues.push({
|
|
4123
|
+
severity: "error",
|
|
4124
|
+
code: "FIELD_WRONG_TYPE",
|
|
4125
|
+
stepId,
|
|
4126
|
+
field: key,
|
|
4127
|
+
message: `\`${key}\` must be ${field.type}.`
|
|
4128
|
+
});
|
|
4129
|
+
continue;
|
|
4130
|
+
}
|
|
4131
|
+
if (field.options && field.options.length > 0 && value !== null && value !== undefined && value !== "") {
|
|
4132
|
+
const allowed = new Set(field.options.map((o) => o.value));
|
|
4133
|
+
const values = Array.isArray(value) ? value : [value];
|
|
4134
|
+
const bad = values.filter((v) => (typeof v === "string" || typeof v === "number") && !allowed.has(v));
|
|
4135
|
+
if (bad.length > 0) {
|
|
4136
|
+
issues.push({
|
|
4137
|
+
severity: "warning",
|
|
4138
|
+
code: "FIELD_BAD_OPTION",
|
|
4139
|
+
stepId,
|
|
4140
|
+
field: key,
|
|
4141
|
+
message: `\`${key}\` must be one of: ${[...allowed].join(", ")}.`
|
|
4142
|
+
});
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
return issues;
|
|
4147
|
+
}
|
|
4148
|
+
function validateStepConfigs(steps) {
|
|
4149
|
+
return steps.flatMap((s) => validateStepConfig(s));
|
|
4150
|
+
}
|
|
4151
|
+
function configErrors(steps) {
|
|
4152
|
+
return validateStepConfigs(steps).filter((i) => i.severity === "error");
|
|
4153
|
+
}
|
|
3999
4154
|
export {
|
|
4000
4155
|
ActionCategory,
|
|
4001
4156
|
ActionStatus,
|
|
@@ -4011,6 +4166,7 @@ export {
|
|
|
4011
4166
|
ForEachConfig,
|
|
4012
4167
|
JoinType,
|
|
4013
4168
|
LogicalOperator,
|
|
4169
|
+
MAX_STEP_CONFIG_BYTES,
|
|
4014
4170
|
ManualTriggerConfig,
|
|
4015
4171
|
NodeStatus,
|
|
4016
4172
|
QueryMode,
|
|
@@ -4024,6 +4180,7 @@ export {
|
|
|
4024
4180
|
buildPathOptions,
|
|
4025
4181
|
collectArrayPaths,
|
|
4026
4182
|
collectArrayPathsFromSample,
|
|
4183
|
+
configErrors,
|
|
4027
4184
|
emailDefinition,
|
|
4028
4185
|
flattenNestedWorkflow,
|
|
4029
4186
|
generateConnectionsFromSteps,
|
|
@@ -4049,5 +4206,7 @@ export {
|
|
|
4049
4206
|
validateEdge,
|
|
4050
4207
|
validateFlowData,
|
|
4051
4208
|
validateNode,
|
|
4209
|
+
validateStepConfig,
|
|
4210
|
+
validateStepConfigs,
|
|
4052
4211
|
validateWorkflow
|
|
4053
4212
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a step's config may contain, enforced where a caller cannot skip it.
|
|
3
|
+
*
|
|
4
|
+
* The editor's rules run in a browser, so they are advice, not a fence. A
|
|
5
|
+
* request posted straight at the API — or modified on its way — reaches
|
|
6
|
+
* `PUT /flows/:id/workflow`, which validated STRUCTURE (ids, connections,
|
|
7
|
+
* cycles) and typed config as `z.record(z.string(), z.unknown())`. Any key,
|
|
8
|
+
* any value, stored verbatim.
|
|
9
|
+
*
|
|
10
|
+
* WHAT THIS DELIBERATELY DOES NOT DO: treat `inputSchema.fields` as an
|
|
11
|
+
* allow-list. Measured against the real estate, 71 of 131 distinct config
|
|
12
|
+
* keys in use are not declared there — `slack_message.text`,
|
|
13
|
+
* `query.visualConfig`, `transform.operation`, `flowId` on nearly every
|
|
14
|
+
* action. `inputSchema` describes the fields the config PANEL renders, and
|
|
15
|
+
* every action with a custom panel stores more than that. Rejecting undeclared
|
|
16
|
+
* keys would refuse most flows on the platform. So an unknown key is a
|
|
17
|
+
* WARNING, never an error.
|
|
18
|
+
*
|
|
19
|
+
* What it does enforce is the part a legitimate client never violates:
|
|
20
|
+
*
|
|
21
|
+
* 1. a declared field's declared TYPE;
|
|
22
|
+
* 2. keys that can poison an object prototype;
|
|
23
|
+
* 3. a size and depth bound, because a config is a form's worth of settings
|
|
24
|
+
* and an unbounded one is a document every reader of that flow pays for
|
|
25
|
+
* (the DEV-366 problem, in a different field).
|
|
26
|
+
*
|
|
27
|
+
* Every one of those was dry-run against all 295 steps of the 77 flows on
|
|
28
|
+
* beta before it was allowed to block anything: 0 oversized (largest 28 KB
|
|
29
|
+
* against a 256 KB cap), 0 deeper than 6 (limit 12), 0 forbidden keys, 0 type
|
|
30
|
+
* mismatches. A rule that refuses data the platform already holds is not a
|
|
31
|
+
* fence, it is an outage.
|
|
32
|
+
*
|
|
33
|
+
* An enumerated field's options are checked but only WARN, for the same
|
|
34
|
+
* reason — see the note at that check.
|
|
35
|
+
*/
|
|
36
|
+
/** Largest config a single step may carry, serialised. */
|
|
37
|
+
export declare const MAX_STEP_CONFIG_BYTES: number;
|
|
38
|
+
export type ConfigIssueCode = "FORBIDDEN_KEY" | "CONFIG_TOO_LARGE" | "CONFIG_TOO_DEEP" | "FIELD_WRONG_TYPE" | "FIELD_BAD_OPTION" | "UNDECLARED_FIELD";
|
|
39
|
+
export interface ConfigIssue {
|
|
40
|
+
severity: "error" | "warning";
|
|
41
|
+
code: ConfigIssueCode;
|
|
42
|
+
stepId: string;
|
|
43
|
+
/** The config key, when the issue is about one. */
|
|
44
|
+
field?: string;
|
|
45
|
+
message: string;
|
|
46
|
+
}
|
|
47
|
+
export interface StepLike {
|
|
48
|
+
id?: unknown;
|
|
49
|
+
actionDefinitionId?: unknown;
|
|
50
|
+
config?: unknown;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check one step's config.
|
|
54
|
+
*
|
|
55
|
+
* Errors block a save. Warnings never do — see the file header on why an
|
|
56
|
+
* undeclared key cannot be an error.
|
|
57
|
+
*/
|
|
58
|
+
export declare function validateStepConfig(step: StepLike): ConfigIssue[];
|
|
59
|
+
/** Every step of a workflow. `steps` may be nested; flatten before calling. */
|
|
60
|
+
export declare function validateStepConfigs(steps: readonly StepLike[]): ConfigIssue[];
|
|
61
|
+
/** Just the blocking ones — what a save path refuses on. */
|
|
62
|
+
export declare function configErrors(steps: readonly StepLike[]): ConfigIssue[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octaviaflow/flow-rules",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The flow action catalog and the rules engine behind Flow Doctor \u2014 one definition of what a step accepts and what makes a flow valid, shared by the editor and the server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|