@octaviaflow/flow-rules 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -23,3 +23,9 @@ export { actionsRegistry, getAllActions, getActionById, getActionsByCategory, }
23
23
  export { validateNode, validateEdge, validateWorkflow, getNodeValidationStatus, getEdgeValidationStatus, type ValidationError, type ValidationResult, } from "./rules/workflowValidator";
24
24
  export { getNodeConfigStatus, type NodeConfigStatus, type NodeConfigStatusResult, } from "./rules/nodeConfigStatus";
25
25
  export { generateWorkflowId, generateStepId, generateEdgeId, generateUUIDv4, } from "./ids";
26
+ export { CONDITION_OPERATORS, type ConditionConfig, type ConditionFilter, type ConditionOperator, } from "./catalog/logic/condition/config";
27
+ export { type ForEachConfig, type ForEachConfigType, type ForEachMode, } from "./catalog/logic/for-each/config";
28
+ export { buildPathOptions, collectArrayPaths, collectArrayPathsFromSample, inferSchemaFromSample, type UpstreamNodeRef, } from "./catalog/logic/for-each/pathOptions";
29
+ export { type QueryMode, type QueryType } from "./catalog/general/query/types";
30
+ export { type VariableField, type VariableSource, type VariableSourceKind, type VariableType, type VariablesConfig, } from "./catalog/utility/variables/config";
31
+ export { type DebugConfig, type DebugConfigType, type DebugMode, type DebugSamplingStrategy, type WatchExpression, } from "./catalog/utility/debug/config";
package/dist/index.js CHANGED
@@ -2872,12 +2872,127 @@ function getEdgeValidationStatus(edgeId, validationResult) {
2872
2872
  return "warning";
2873
2873
  return "valid";
2874
2874
  }
2875
+ // src/catalog/logic/condition/config.ts
2876
+ var CONDITION_OPERATORS = [
2877
+ { id: "equals", label: "Equals", needsValue: true },
2878
+ { id: "not_equals", label: "Not Equals", needsValue: true },
2879
+ { id: "greater_than", label: "Greater Than", needsValue: true },
2880
+ { id: "greater_than_equals", label: "Greater Than or Equals", needsValue: true },
2881
+ { id: "less_than", label: "Less Than", needsValue: true },
2882
+ { id: "less_than_equals", label: "Less Than or Equals", needsValue: true },
2883
+ { id: "like", label: "Like", needsValue: true },
2884
+ { id: "contains", label: "Contains", needsValue: true },
2885
+ { id: "starts_with", label: "Starts With", needsValue: true },
2886
+ { id: "ends_with", label: "Ends With", needsValue: true },
2887
+ { id: "is_null", label: "Is Null", needsValue: false },
2888
+ { id: "is_not_null", label: "Is Not Null", needsValue: false },
2889
+ { id: "is_empty", label: "Is Empty", needsValue: false }
2890
+ ];
2891
+ // src/catalog/logic/for-each/pathOptions.ts
2892
+ function inferSchemaFromSample(sample) {
2893
+ const properties = {};
2894
+ for (const [key, value] of Object.entries(sample)) {
2895
+ if (value === null || value === undefined) {
2896
+ properties[key] = { type: "string" };
2897
+ } else if (Array.isArray(value)) {
2898
+ if (value.length > 0 && typeof value[0] === "object" && value[0] !== null) {
2899
+ properties[key] = { type: "array", items: inferSchemaFromSample(value[0]) };
2900
+ } else {
2901
+ properties[key] = { type: "array" };
2902
+ }
2903
+ } else if (typeof value === "object") {
2904
+ properties[key] = inferSchemaFromSample(value);
2905
+ } else if (typeof value === "number") {
2906
+ properties[key] = { type: "number" };
2907
+ } else if (typeof value === "boolean") {
2908
+ properties[key] = { type: "boolean" };
2909
+ } else {
2910
+ properties[key] = { type: "string" };
2911
+ }
2912
+ }
2913
+ return { type: "object", properties };
2914
+ }
2915
+ function collectArrayPaths(schema, prefix, add, depth = 0) {
2916
+ if (!schema || typeof schema !== "object" || depth > 8)
2917
+ return;
2918
+ if (schema.type === "array") {
2919
+ if (prefix) {
2920
+ const itemsType = schema.items?.type;
2921
+ const label = itemsType === "object" ? "array of objects" : "array";
2922
+ add(prefix, `${prefix} (${label})`, `Iterate over "${prefix}"`);
2923
+ }
2924
+ if (schema.items) {
2925
+ collectArrayPaths(schema.items, prefix, add, depth + 1);
2926
+ }
2927
+ return;
2928
+ }
2929
+ if (schema.type === "object" && schema.properties) {
2930
+ for (const [key, child] of Object.entries(schema.properties)) {
2931
+ const next = prefix ? `${prefix}.${key}` : key;
2932
+ collectArrayPaths(child, next, add, depth + 1);
2933
+ }
2934
+ }
2935
+ }
2936
+ function collectArrayPathsFromSample(sample, prefix, add, depth = 0) {
2937
+ if (!sample || typeof sample !== "object" || depth > 8)
2938
+ return;
2939
+ if (Array.isArray(sample)) {
2940
+ if (prefix) {
2941
+ const itemsObj = sample.length > 0 && typeof sample[0] === "object" && sample[0] !== null;
2942
+ const label = itemsObj ? "array of objects" : "array";
2943
+ add(prefix, `${prefix} (${label})`, `Iterate over "${prefix}"`);
2944
+ }
2945
+ if (sample.length > 0) {
2946
+ collectArrayPathsFromSample(sample[0], prefix, add, depth + 1);
2947
+ }
2948
+ return;
2949
+ }
2950
+ for (const [key, value] of Object.entries(sample)) {
2951
+ const next = prefix ? `${prefix}.${key}` : key;
2952
+ collectArrayPathsFromSample(value, next, add, depth + 1);
2953
+ }
2954
+ }
2955
+ function buildPathOptions(upstreamNodes) {
2956
+ const paths = [];
2957
+ const seen = new Set;
2958
+ const add = (id, text, description) => {
2959
+ if (seen.has(id))
2960
+ return;
2961
+ seen.add(id);
2962
+ paths.push({ id, text, description });
2963
+ };
2964
+ if (upstreamNodes) {
2965
+ for (const node of upstreamNodes) {
2966
+ const label = node.label || node.type || "Upstream";
2967
+ const queryTable = node.config?.visualConfig?.tables?.[0];
2968
+ add("data", queryTable ? `${queryTable} (${label})` : `All records (${label})`, queryTable ? `Iterate over every ${queryTable} record` : "Iterate over every record from upstream");
2969
+ const schema = node.outputSchema || node.config?._outputSchema;
2970
+ if (schema)
2971
+ collectArrayPaths(schema, "", add);
2972
+ const output = node.executionData?.output;
2973
+ if (output) {
2974
+ const records = Array.isArray(output.data) ? output.data : Array.isArray(output) ? output : null;
2975
+ if (records && records.length > 0 && typeof records[0] === "object") {
2976
+ collectArrayPathsFromSample(records[0], "", add);
2977
+ }
2978
+ }
2979
+ }
2980
+ }
2981
+ if (paths.length === 0) {
2982
+ add("data", "data (upstream output)");
2983
+ }
2984
+ return paths;
2985
+ }
2875
2986
  export {
2876
2987
  ActionCategory,
2877
2988
  ActionStatus,
2878
2989
  ActionType,
2990
+ CONDITION_OPERATORS,
2879
2991
  FieldType,
2880
2992
  actionsRegistry,
2993
+ buildPathOptions,
2994
+ collectArrayPaths,
2995
+ collectArrayPathsFromSample,
2881
2996
  generateEdgeId,
2882
2997
  generateStepId,
2883
2998
  generateUUIDv4,
@@ -2888,6 +3003,7 @@ export {
2888
3003
  getEdgeValidationStatus,
2889
3004
  getNodeConfigStatus,
2890
3005
  getNodeValidationStatus,
3006
+ inferSchemaFromSample,
2891
3007
  validateEdge,
2892
3008
  validateNode,
2893
3009
  validateWorkflow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octaviaflow/flow-rules",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "The flow action catalog and the rules engine behind Flow Doctor — 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.js",