@timeax/digital-service-engine 0.2.3 → 0.2.5
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/core/index.cjs +145 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +8 -1
- package/dist/core/index.d.ts +8 -1
- package/dist/core/index.js +145 -0
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +236 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +11 -1
- package/dist/react/index.d.ts +11 -1
- package/dist/react/index.js +236 -0
- package/dist/react/index.js.map +1 -1
- package/dist/schema/index.d.cts +9 -2
- package/dist/schema/index.d.ts +9 -2
- package/dist/workspace/index.cjs +227 -0
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.d.cts +5 -1
- package/dist/workspace/index.d.ts +5 -1
- package/dist/workspace/index.js +227 -0
- package/dist/workspace/index.js.map +1 -1
- package/package.json +6 -5
- package/schema/editor-snapshot.schema.json +6 -0
- package/schema/order-snapshot.schema.json +667 -0
- package/schema/service-props.schema.json +6 -0
package/dist/schema/index.d.cts
CHANGED
|
@@ -68,6 +68,10 @@ type SnapshotContext = {
|
|
|
68
68
|
requireConstraintFit: boolean;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
+
type OrderKindSource = {
|
|
72
|
+
nodeId: string;
|
|
73
|
+
nodeKind: "tag" | "field" | "option";
|
|
74
|
+
};
|
|
71
75
|
type OrderSnapshot = {
|
|
72
76
|
version: "1";
|
|
73
77
|
mode: "prod" | "dev";
|
|
@@ -94,6 +98,8 @@ type OrderSnapshot = {
|
|
|
94
98
|
};
|
|
95
99
|
min: number;
|
|
96
100
|
max: number;
|
|
101
|
+
orderKind?: string | null;
|
|
102
|
+
orderKindSource?: OrderKindSource | null;
|
|
97
103
|
services: Array<string | number>;
|
|
98
104
|
serviceMap: Record<string, Array<string | number>>;
|
|
99
105
|
fallbacks?: ServiceFallbacks;
|
|
@@ -171,7 +177,7 @@ type NodeRef = {
|
|
|
171
177
|
};
|
|
172
178
|
type NodeMap = Map<string, NodeRef>;
|
|
173
179
|
|
|
174
|
-
type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "option_include_exclude_conflict" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern";
|
|
180
|
+
type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "option_include_exclude_conflict" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
|
|
175
181
|
type ValidationError = {
|
|
176
182
|
code: ValidationCode;
|
|
177
183
|
message: string;
|
|
@@ -627,6 +633,7 @@ type Tag = {
|
|
|
627
633
|
};
|
|
628
634
|
type ServiceProps = {
|
|
629
635
|
order_for_tags?: Record<string, string[]>;
|
|
636
|
+
orderKinds?: Record<string, string>;
|
|
630
637
|
filters: Tag[];
|
|
631
638
|
fields: Field[];
|
|
632
639
|
includes_for_buttons?: Record<string, string[]>;
|
|
@@ -981,4 +988,4 @@ type EditorSnapshot = {
|
|
|
981
988
|
/** Exported alias so the schema generator can target an array */
|
|
982
989
|
type AdminPolicies = DynamicRule[];
|
|
983
990
|
|
|
984
|
-
export { type AdminPolicies, type BaseFieldUI, type ButtonValue, type CanvasEvents, type CanvasOptions, type CanvasState, type CatalogGroupNode, type CatalogId, type CatalogNode, type CatalogNodeBase, type CatalogNodeKind, type CatalogServiceId, type CatalogSmartGroupNode, type CatalogSmartRule, type CatalogViewMode, type Command, type CommentAnchor, type CommentId, type CommentMessage, type CommentNode, type CommentThread, type ConnectKind, type ConstraintKey, type DgpServiceCapability, type DgpServiceMap, type DraftWire, type DynamicRule, type EdgeKind, type EdgeRoute, type EdgeView, type EditorEvents, type EditorOptions, type EditorSnapshot, type FallbackCandidateCheck, type FallbackCheckReason, type FallbackCheckResult, type FallbackDiagnostics, type FallbackEditor, type FallbackEditorOptions, type FallbackEditorServiceMap, type FallbackEditorServiceRecord, type FallbackEditorState, type FallbackEligibleSource, type FallbackMutationOptions, type FallbackRegistration, type FallbackRegistrationScope, type FallbackScopeRef, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldValidationOp, type FieldValidationRule, type FieldValidationValueBy, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, type OrderSnapshot, type PricingRole, type QuantityMark, type QuantityRule, type RatePolicy, type Scalar, type ServiceCatalogState, type ServiceEstimates, type ServiceFallback, type ServiceFallbacks, type ServiceFlag, type ServiceFlags, type ServiceIdRef, type ServiceProps, type ServicePropsNotice, type ServiceWhereClause, type ServiceWhereOp, type SnapshotContext, type SpeedEstimate, type Tag, type ThreadId, type TimeRangeEstimate, type Ui, type UiAnyOf, type UiArray, type UiBoolean, type UiNumber, type UiObject, type UiString, type UiValue, type UtilityLineItem, type UtilityMark, type UtilityMode, type ValidationCode, type ValidationError, type ValidatorOptions, type Viewport, type WithQuantityDefault, createFallbackEditor };
|
|
991
|
+
export { type AdminPolicies, type BaseFieldUI, type ButtonValue, type CanvasEvents, type CanvasOptions, type CanvasState, type CatalogGroupNode, type CatalogId, type CatalogNode, type CatalogNodeBase, type CatalogNodeKind, type CatalogServiceId, type CatalogSmartGroupNode, type CatalogSmartRule, type CatalogViewMode, type Command, type CommentAnchor, type CommentId, type CommentMessage, type CommentNode, type CommentThread, type ConnectKind, type ConstraintKey, type DgpServiceCapability, type DgpServiceMap, type DraftWire, type DynamicRule, type EdgeKind, type EdgeRoute, type EdgeView, type EditorEvents, type EditorOptions, type EditorSnapshot, type FallbackCandidateCheck, type FallbackCheckReason, type FallbackCheckResult, type FallbackDiagnostics, type FallbackEditor, type FallbackEditorOptions, type FallbackEditorServiceMap, type FallbackEditorServiceRecord, type FallbackEditorState, type FallbackEligibleSource, type FallbackMutationOptions, type FallbackRegistration, type FallbackRegistrationScope, type FallbackScopeRef, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldValidationOp, type FieldValidationRule, type FieldValidationValueBy, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, type OrderKindSource, type OrderSnapshot, type PricingRole, type QuantityMark, type QuantityRule, type RatePolicy, type Scalar, type ServiceCatalogState, type ServiceEstimates, type ServiceFallback, type ServiceFallbacks, type ServiceFlag, type ServiceFlags, type ServiceIdRef, type ServiceProps, type ServicePropsNotice, type ServiceWhereClause, type ServiceWhereOp, type SnapshotContext, type SpeedEstimate, type Tag, type ThreadId, type TimeRangeEstimate, type Ui, type UiAnyOf, type UiArray, type UiBoolean, type UiNumber, type UiObject, type UiString, type UiValue, type UtilityLineItem, type UtilityMark, type UtilityMode, type ValidationCode, type ValidationError, type ValidatorOptions, type Viewport, type WithQuantityDefault, createFallbackEditor };
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -68,6 +68,10 @@ type SnapshotContext = {
|
|
|
68
68
|
requireConstraintFit: boolean;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
+
type OrderKindSource = {
|
|
72
|
+
nodeId: string;
|
|
73
|
+
nodeKind: "tag" | "field" | "option";
|
|
74
|
+
};
|
|
71
75
|
type OrderSnapshot = {
|
|
72
76
|
version: "1";
|
|
73
77
|
mode: "prod" | "dev";
|
|
@@ -94,6 +98,8 @@ type OrderSnapshot = {
|
|
|
94
98
|
};
|
|
95
99
|
min: number;
|
|
96
100
|
max: number;
|
|
101
|
+
orderKind?: string | null;
|
|
102
|
+
orderKindSource?: OrderKindSource | null;
|
|
97
103
|
services: Array<string | number>;
|
|
98
104
|
serviceMap: Record<string, Array<string | number>>;
|
|
99
105
|
fallbacks?: ServiceFallbacks;
|
|
@@ -171,7 +177,7 @@ type NodeRef = {
|
|
|
171
177
|
};
|
|
172
178
|
type NodeMap = Map<string, NodeRef>;
|
|
173
179
|
|
|
174
|
-
type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "option_include_exclude_conflict" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern";
|
|
180
|
+
type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "option_include_exclude_conflict" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
|
|
175
181
|
type ValidationError = {
|
|
176
182
|
code: ValidationCode;
|
|
177
183
|
message: string;
|
|
@@ -627,6 +633,7 @@ type Tag = {
|
|
|
627
633
|
};
|
|
628
634
|
type ServiceProps = {
|
|
629
635
|
order_for_tags?: Record<string, string[]>;
|
|
636
|
+
orderKinds?: Record<string, string>;
|
|
630
637
|
filters: Tag[];
|
|
631
638
|
fields: Field[];
|
|
632
639
|
includes_for_buttons?: Record<string, string[]>;
|
|
@@ -981,4 +988,4 @@ type EditorSnapshot = {
|
|
|
981
988
|
/** Exported alias so the schema generator can target an array */
|
|
982
989
|
type AdminPolicies = DynamicRule[];
|
|
983
990
|
|
|
984
|
-
export { type AdminPolicies, type BaseFieldUI, type ButtonValue, type CanvasEvents, type CanvasOptions, type CanvasState, type CatalogGroupNode, type CatalogId, type CatalogNode, type CatalogNodeBase, type CatalogNodeKind, type CatalogServiceId, type CatalogSmartGroupNode, type CatalogSmartRule, type CatalogViewMode, type Command, type CommentAnchor, type CommentId, type CommentMessage, type CommentNode, type CommentThread, type ConnectKind, type ConstraintKey, type DgpServiceCapability, type DgpServiceMap, type DraftWire, type DynamicRule, type EdgeKind, type EdgeRoute, type EdgeView, type EditorEvents, type EditorOptions, type EditorSnapshot, type FallbackCandidateCheck, type FallbackCheckReason, type FallbackCheckResult, type FallbackDiagnostics, type FallbackEditor, type FallbackEditorOptions, type FallbackEditorServiceMap, type FallbackEditorServiceRecord, type FallbackEditorState, type FallbackEligibleSource, type FallbackMutationOptions, type FallbackRegistration, type FallbackRegistrationScope, type FallbackScopeRef, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldValidationOp, type FieldValidationRule, type FieldValidationValueBy, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, type OrderSnapshot, type PricingRole, type QuantityMark, type QuantityRule, type RatePolicy, type Scalar, type ServiceCatalogState, type ServiceEstimates, type ServiceFallback, type ServiceFallbacks, type ServiceFlag, type ServiceFlags, type ServiceIdRef, type ServiceProps, type ServicePropsNotice, type ServiceWhereClause, type ServiceWhereOp, type SnapshotContext, type SpeedEstimate, type Tag, type ThreadId, type TimeRangeEstimate, type Ui, type UiAnyOf, type UiArray, type UiBoolean, type UiNumber, type UiObject, type UiString, type UiValue, type UtilityLineItem, type UtilityMark, type UtilityMode, type ValidationCode, type ValidationError, type ValidatorOptions, type Viewport, type WithQuantityDefault, createFallbackEditor };
|
|
991
|
+
export { type AdminPolicies, type BaseFieldUI, type ButtonValue, type CanvasEvents, type CanvasOptions, type CanvasState, type CatalogGroupNode, type CatalogId, type CatalogNode, type CatalogNodeBase, type CatalogNodeKind, type CatalogServiceId, type CatalogSmartGroupNode, type CatalogSmartRule, type CatalogViewMode, type Command, type CommentAnchor, type CommentId, type CommentMessage, type CommentNode, type CommentThread, type ConnectKind, type ConstraintKey, type DgpServiceCapability, type DgpServiceMap, type DraftWire, type DynamicRule, type EdgeKind, type EdgeRoute, type EdgeView, type EditorEvents, type EditorOptions, type EditorSnapshot, type FallbackCandidateCheck, type FallbackCheckReason, type FallbackCheckResult, type FallbackDiagnostics, type FallbackEditor, type FallbackEditorOptions, type FallbackEditorServiceMap, type FallbackEditorServiceRecord, type FallbackEditorState, type FallbackEligibleSource, type FallbackMutationOptions, type FallbackRegistration, type FallbackRegistrationScope, type FallbackScopeRef, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldValidationOp, type FieldValidationRule, type FieldValidationValueBy, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, type OrderKindSource, type OrderSnapshot, type PricingRole, type QuantityMark, type QuantityRule, type RatePolicy, type Scalar, type ServiceCatalogState, type ServiceEstimates, type ServiceFallback, type ServiceFallbacks, type ServiceFlag, type ServiceFlags, type ServiceIdRef, type ServiceProps, type ServicePropsNotice, type ServiceWhereClause, type ServiceWhereOp, type SnapshotContext, type SpeedEstimate, type Tag, type ThreadId, type TimeRangeEstimate, type Ui, type UiAnyOf, type UiArray, type UiBoolean, type UiNumber, type UiObject, type UiString, type UiValue, type UtilityLineItem, type UtilityMark, type UtilityMode, type ValidationCode, type ValidationError, type ValidatorOptions, type Viewport, type WithQuantityDefault, createFallbackEditor };
|
package/dist/workspace/index.cjs
CHANGED
|
@@ -3527,6 +3527,7 @@ function normalise(input, opts = {}) {
|
|
|
3527
3527
|
const excludes_for_buttons = toStringArrayMap(
|
|
3528
3528
|
obj.excludes_for_buttons
|
|
3529
3529
|
);
|
|
3530
|
+
const orderKinds = toStringMap(obj.orderKinds);
|
|
3530
3531
|
const notices = toNoticeArray(obj.notices);
|
|
3531
3532
|
let filters = rawFilters.map((t) => coerceTag(t, constraints));
|
|
3532
3533
|
const fields = rawFields.map((f) => coerceField(f, defRole));
|
|
@@ -3538,6 +3539,7 @@ function normalise(input, opts = {}) {
|
|
|
3538
3539
|
filters,
|
|
3539
3540
|
fields,
|
|
3540
3541
|
order_for_tags: obj.order_for_tags,
|
|
3542
|
+
...isNonEmpty(orderKinds) && { orderKinds },
|
|
3541
3543
|
...isNonEmpty(includes_for_buttons) && { includes_for_buttons },
|
|
3542
3544
|
...isNonEmpty(excludes_for_buttons) && { excludes_for_buttons },
|
|
3543
3545
|
...fallbacks && (isNonEmpty(fallbacks.nodes) || isNonEmpty(fallbacks.global)) && {
|
|
@@ -3748,6 +3750,15 @@ function normaliseBindId(bind) {
|
|
|
3748
3750
|
}
|
|
3749
3751
|
return void 0;
|
|
3750
3752
|
}
|
|
3753
|
+
function toStringMap(src) {
|
|
3754
|
+
if (!src || typeof src !== "object") return void 0;
|
|
3755
|
+
const out = {};
|
|
3756
|
+
for (const [k, v] of Object.entries(src)) {
|
|
3757
|
+
if (!k || typeof v !== "string") continue;
|
|
3758
|
+
out[k] = v;
|
|
3759
|
+
}
|
|
3760
|
+
return Object.keys(out).length ? out : void 0;
|
|
3761
|
+
}
|
|
3751
3762
|
function toStringArrayMap(src) {
|
|
3752
3763
|
if (!src || typeof src !== "object") return void 0;
|
|
3753
3764
|
const out = {};
|
|
@@ -4566,6 +4577,129 @@ function validateOptionMaps(v) {
|
|
|
4566
4577
|
}
|
|
4567
4578
|
}
|
|
4568
4579
|
|
|
4580
|
+
// src/utils/order-kind.ts
|
|
4581
|
+
function normalizeSelectedTriggerKey(key, nodeMap) {
|
|
4582
|
+
if (!key) return void 0;
|
|
4583
|
+
const compositeIdx = key.indexOf("::");
|
|
4584
|
+
if (compositeIdx !== -1) {
|
|
4585
|
+
const fieldId = key.slice(0, compositeIdx).trim();
|
|
4586
|
+
const optionId = key.slice(compositeIdx + 2).trim();
|
|
4587
|
+
if (optionId) {
|
|
4588
|
+
const optionRef = nodeMap.get(optionId);
|
|
4589
|
+
if ((optionRef == null ? void 0 : optionRef.kind) === "option") {
|
|
4590
|
+
return { nodeId: optionRef.id, nodeKind: "option" };
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
if (fieldId) {
|
|
4594
|
+
const fieldRef = nodeMap.get(fieldId);
|
|
4595
|
+
if ((fieldRef == null ? void 0 : fieldRef.kind) === "field") {
|
|
4596
|
+
return { nodeId: fieldRef.id, nodeKind: "field" };
|
|
4597
|
+
}
|
|
4598
|
+
}
|
|
4599
|
+
return void 0;
|
|
4600
|
+
}
|
|
4601
|
+
const ref = nodeMap.get(key);
|
|
4602
|
+
if (!ref) return void 0;
|
|
4603
|
+
if (ref.kind !== "field" && ref.kind !== "option") return void 0;
|
|
4604
|
+
return { nodeId: ref.id, nodeKind: ref.kind };
|
|
4605
|
+
}
|
|
4606
|
+
function normalizeSelectedOrderKindTriggers(selectedTriggerKeys, nodeMap) {
|
|
4607
|
+
if (!selectedTriggerKeys) return [];
|
|
4608
|
+
const out = [];
|
|
4609
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4610
|
+
for (const rawKey of selectedTriggerKeys) {
|
|
4611
|
+
const key = String(rawKey != null ? rawKey : "");
|
|
4612
|
+
const normalized = normalizeSelectedTriggerKey(key, nodeMap);
|
|
4613
|
+
if (!normalized) continue;
|
|
4614
|
+
const dedupeKey = `${normalized.nodeKind}:${normalized.nodeId}`;
|
|
4615
|
+
if (seen.has(dedupeKey)) continue;
|
|
4616
|
+
seen.add(dedupeKey);
|
|
4617
|
+
out.push(normalized);
|
|
4618
|
+
}
|
|
4619
|
+
return out;
|
|
4620
|
+
}
|
|
4621
|
+
function resolveOrderKind(params) {
|
|
4622
|
+
var _a, _b;
|
|
4623
|
+
const nodeMap = (_a = params.nodeMap) != null ? _a : buildNodeMap(params.props);
|
|
4624
|
+
const orderKinds = (_b = params.props.orderKinds) != null ? _b : {};
|
|
4625
|
+
const normalizedSelected = normalizeSelectedOrderKindTriggers(
|
|
4626
|
+
params.selectedTriggerKeys,
|
|
4627
|
+
nodeMap
|
|
4628
|
+
);
|
|
4629
|
+
const selectedKindToSource = /* @__PURE__ */ new Map();
|
|
4630
|
+
const selectedNodeIdsForKinds = /* @__PURE__ */ new Map();
|
|
4631
|
+
for (const trigger of normalizedSelected) {
|
|
4632
|
+
const mappedKind = orderKinds[trigger.nodeId];
|
|
4633
|
+
if (typeof mappedKind !== "string") continue;
|
|
4634
|
+
if (!selectedKindToSource.has(mappedKind)) {
|
|
4635
|
+
selectedKindToSource.set(mappedKind, {
|
|
4636
|
+
nodeId: trigger.nodeId,
|
|
4637
|
+
nodeKind: trigger.nodeKind
|
|
4638
|
+
});
|
|
4639
|
+
}
|
|
4640
|
+
if (!selectedNodeIdsForKinds.has(mappedKind)) {
|
|
4641
|
+
selectedNodeIdsForKinds.set(mappedKind, /* @__PURE__ */ new Set());
|
|
4642
|
+
}
|
|
4643
|
+
selectedNodeIdsForKinds.get(mappedKind).add(trigger.nodeId);
|
|
4644
|
+
}
|
|
4645
|
+
const selectedKinds = Array.from(selectedKindToSource.keys());
|
|
4646
|
+
if (selectedKinds.length > 1) {
|
|
4647
|
+
const conflictingNodeIds = Array.from(selectedNodeIdsForKinds.values()).flatMap((ids) => Array.from(ids)).filter((id, idx, arr) => arr.indexOf(id) === idx);
|
|
4648
|
+
return {
|
|
4649
|
+
kind: null,
|
|
4650
|
+
source: null,
|
|
4651
|
+
error: "multiple_order_kinds_selected",
|
|
4652
|
+
conflictingKinds: selectedKinds,
|
|
4653
|
+
conflictingNodeIds
|
|
4654
|
+
};
|
|
4655
|
+
}
|
|
4656
|
+
if (selectedKinds.length === 1) {
|
|
4657
|
+
const selectedKind = selectedKinds[0];
|
|
4658
|
+
return {
|
|
4659
|
+
kind: selectedKind,
|
|
4660
|
+
source: selectedKindToSource.get(selectedKind)
|
|
4661
|
+
};
|
|
4662
|
+
}
|
|
4663
|
+
const activeTagId = params.activeTagId;
|
|
4664
|
+
if (activeTagId) {
|
|
4665
|
+
const tagKind = orderKinds[activeTagId];
|
|
4666
|
+
if (typeof tagKind === "string") {
|
|
4667
|
+
return {
|
|
4668
|
+
kind: tagKind,
|
|
4669
|
+
source: { nodeId: activeTagId, nodeKind: "tag" }
|
|
4670
|
+
};
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4673
|
+
return { kind: null, source: null };
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4676
|
+
// src/core/validate/steps/order-kinds.ts
|
|
4677
|
+
function validateOrderKinds(v) {
|
|
4678
|
+
var _a, _b, _c;
|
|
4679
|
+
const selectedTriggerKeys = Array.from((_a = v.selectedKeys) != null ? _a : []);
|
|
4680
|
+
if (!selectedTriggerKeys.length) return;
|
|
4681
|
+
const resolved = resolveOrderKind({
|
|
4682
|
+
props: v.props,
|
|
4683
|
+
selectedTriggerKeys,
|
|
4684
|
+
nodeMap: v.nodeMap
|
|
4685
|
+
});
|
|
4686
|
+
if (resolved.error !== "multiple_order_kinds_selected") return;
|
|
4687
|
+
const conflicts = (_b = resolved.conflictingKinds) != null ? _b : [];
|
|
4688
|
+
const affected = (_c = resolved.conflictingNodeIds) != null ? _c : [];
|
|
4689
|
+
v.errors.push({
|
|
4690
|
+
code: "multiple_order_kinds_selected",
|
|
4691
|
+
severity: "error",
|
|
4692
|
+
message: "Multiple selected triggers resolve to different order kinds. Select triggers that resolve to a single order kind.",
|
|
4693
|
+
details: withAffected(
|
|
4694
|
+
{
|
|
4695
|
+
conflictingKinds: conflicts,
|
|
4696
|
+
conflictingNodeIds: affected
|
|
4697
|
+
},
|
|
4698
|
+
affected
|
|
4699
|
+
)
|
|
4700
|
+
});
|
|
4701
|
+
}
|
|
4702
|
+
|
|
4569
4703
|
// src/core/validate/steps/service-vs-input.ts
|
|
4570
4704
|
function validateServiceVsUserInput(v) {
|
|
4571
4705
|
for (const f of v.fields) {
|
|
@@ -5889,6 +6023,7 @@ var BuilderImpl = class {
|
|
|
5889
6023
|
const out = {
|
|
5890
6024
|
filters: this.props.filters.slice(),
|
|
5891
6025
|
fields,
|
|
6026
|
+
...this.props.orderKinds ? { orderKinds: this.props.orderKinds } : {},
|
|
5892
6027
|
...includes_for_buttons && { includes_for_buttons },
|
|
5893
6028
|
...excludes_for_buttons && { excludes_for_buttons },
|
|
5894
6029
|
schema_version: (_e = this.props.schema_version) != null ? _e : "1.0",
|
|
@@ -6221,6 +6356,7 @@ function validate(props, ctx = {}) {
|
|
|
6221
6356
|
validateStructure(v);
|
|
6222
6357
|
validateIdentity(v);
|
|
6223
6358
|
validateOptionMaps(v);
|
|
6359
|
+
validateOrderKinds(v);
|
|
6224
6360
|
v.fieldsVisibleUnder = createFieldsVisibleUnder(v);
|
|
6225
6361
|
const visSim = readVisibilitySimOpts(options);
|
|
6226
6362
|
validateVisibility(v, visSim);
|
|
@@ -8143,6 +8279,88 @@ function normalizeQuantityRule(input) {
|
|
|
8143
8279
|
return out;
|
|
8144
8280
|
}
|
|
8145
8281
|
|
|
8282
|
+
// src/react/canvas/editor/editor-order-kinds.ts
|
|
8283
|
+
function normalizeKind(kind) {
|
|
8284
|
+
const next = String(kind != null ? kind : "").trim();
|
|
8285
|
+
if (!next) {
|
|
8286
|
+
throw new Error("setOrderKind: kind must be a non-empty string");
|
|
8287
|
+
}
|
|
8288
|
+
return next;
|
|
8289
|
+
}
|
|
8290
|
+
function assertCanonicalNodeId(ctx, nodeId) {
|
|
8291
|
+
const id = String(nodeId != null ? nodeId : "").trim();
|
|
8292
|
+
if (!id) throw new Error("setOrderKind: nodeId is required");
|
|
8293
|
+
if (id.includes("::")) {
|
|
8294
|
+
throw new Error(
|
|
8295
|
+
"setOrderKind: composite/internal trigger keys are not allowed; use canonical tag/field/option ids"
|
|
8296
|
+
);
|
|
8297
|
+
}
|
|
8298
|
+
if (!ctx.isTagId(id) && !ctx.isFieldId(id) && !ctx.isOptionId(id)) {
|
|
8299
|
+
throw new Error(
|
|
8300
|
+
`setOrderKind: node id '${id}' is not a known tag, field, or option`
|
|
8301
|
+
);
|
|
8302
|
+
}
|
|
8303
|
+
if (ctx.isFieldId(id)) {
|
|
8304
|
+
const node = ctx.getNode(id);
|
|
8305
|
+
if (node.kind !== "field" || !isActualButtonField(node.data)) {
|
|
8306
|
+
throw new Error(
|
|
8307
|
+
`setOrderKind: field '${id}' must be a button field without options`
|
|
8308
|
+
);
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
}
|
|
8312
|
+
function setOrderKind(ctx, nodeId, kind) {
|
|
8313
|
+
const id = String(nodeId != null ? nodeId : "").trim();
|
|
8314
|
+
const nextKind = normalizeKind(kind);
|
|
8315
|
+
assertCanonicalNodeId(ctx, id);
|
|
8316
|
+
ctx.exec({
|
|
8317
|
+
name: "setOrderKind",
|
|
8318
|
+
do: () => ctx.patchProps((p) => {
|
|
8319
|
+
if (!p.orderKinds) p.orderKinds = {};
|
|
8320
|
+
p.orderKinds[id] = nextKind;
|
|
8321
|
+
}),
|
|
8322
|
+
undo: () => ctx.undo()
|
|
8323
|
+
});
|
|
8324
|
+
}
|
|
8325
|
+
function deleteOrderKind(ctx, nodeId) {
|
|
8326
|
+
const id = String(nodeId != null ? nodeId : "").trim();
|
|
8327
|
+
if (!id) return;
|
|
8328
|
+
ctx.exec({
|
|
8329
|
+
name: "deleteOrderKind",
|
|
8330
|
+
do: () => ctx.patchProps((p) => {
|
|
8331
|
+
if (!p.orderKinds || !Object.prototype.hasOwnProperty.call(p.orderKinds, id)) {
|
|
8332
|
+
return;
|
|
8333
|
+
}
|
|
8334
|
+
delete p.orderKinds[id];
|
|
8335
|
+
if (!Object.keys(p.orderKinds).length) {
|
|
8336
|
+
delete p.orderKinds;
|
|
8337
|
+
}
|
|
8338
|
+
}),
|
|
8339
|
+
undo: () => ctx.undo()
|
|
8340
|
+
});
|
|
8341
|
+
}
|
|
8342
|
+
function pruneOrderKind(ctx, kind) {
|
|
8343
|
+
const target = normalizeKind(kind);
|
|
8344
|
+
let removedCount = 0;
|
|
8345
|
+
ctx.exec({
|
|
8346
|
+
name: "pruneOrderKind",
|
|
8347
|
+
do: () => ctx.patchProps((p) => {
|
|
8348
|
+
if (!p.orderKinds) return;
|
|
8349
|
+
removedCount = 0;
|
|
8350
|
+
for (const [nodeId, mapped] of Object.entries(p.orderKinds)) {
|
|
8351
|
+
if (mapped !== target) continue;
|
|
8352
|
+
delete p.orderKinds[nodeId];
|
|
8353
|
+
removedCount++;
|
|
8354
|
+
}
|
|
8355
|
+
if (!Object.keys(p.orderKinds).length) {
|
|
8356
|
+
delete p.orderKinds;
|
|
8357
|
+
}
|
|
8358
|
+
}),
|
|
8359
|
+
undo: () => ctx.undo()
|
|
8360
|
+
});
|
|
8361
|
+
return removedCount;
|
|
8362
|
+
}
|
|
8363
|
+
|
|
8146
8364
|
// src/react/canvas/editor/editor-relations.ts
|
|
8147
8365
|
function wouldCreateTagCycle(_ctx, p, parentId, childId) {
|
|
8148
8366
|
var _a, _b;
|
|
@@ -9123,6 +9341,15 @@ var Editor = class {
|
|
|
9123
9341
|
clearFieldValidation(id) {
|
|
9124
9342
|
return clearFieldValidation(this.moduleCtx(), id);
|
|
9125
9343
|
}
|
|
9344
|
+
setOrderKind(nodeId, kind) {
|
|
9345
|
+
return setOrderKind(this.moduleCtx(), nodeId, kind);
|
|
9346
|
+
}
|
|
9347
|
+
deleteOrderKind(nodeId) {
|
|
9348
|
+
return deleteOrderKind(this.moduleCtx(), nodeId);
|
|
9349
|
+
}
|
|
9350
|
+
pruneKind(kind) {
|
|
9351
|
+
return pruneOrderKind(this.moduleCtx(), kind);
|
|
9352
|
+
}
|
|
9126
9353
|
getCatalog() {
|
|
9127
9354
|
return (0, import_lodash_es4.cloneDeep)(this.catalog);
|
|
9128
9355
|
}
|