@timeax/digital-service-engine 0.2.0 → 0.2.1
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 +64 -22
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +9 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.js +64 -22
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +66 -22
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +9 -0
- package/dist/react/index.d.ts +9 -0
- package/dist/react/index.js +66 -22
- package/dist/react/index.js.map +1 -1
- package/dist/schema/index.d.cts +5 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/workspace/index.cjs +116 -32
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.d.cts +15 -0
- package/dist/workspace/index.d.ts +15 -0
- package/dist/workspace/index.js +116 -32
- package/dist/workspace/index.js.map +1 -1
- package/package.json +1 -1
package/dist/schema/index.d.cts
CHANGED
|
@@ -224,6 +224,11 @@ type ValidatorOptions = {
|
|
|
224
224
|
selectedOptionKeys?: string[];
|
|
225
225
|
globalUtilityGuard?: boolean;
|
|
226
226
|
policies?: DynamicRule[];
|
|
227
|
+
/**
|
|
228
|
+
* Global/base rate policy used by validation and service filtering.
|
|
229
|
+
* This is intentionally separate from fallbackSettings.ratePolicy.
|
|
230
|
+
*/
|
|
231
|
+
ratePolicy?: RatePolicy;
|
|
227
232
|
fallbackSettings?: FallbackSettings;
|
|
228
233
|
};
|
|
229
234
|
type RatePolicy = {
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -224,6 +224,11 @@ type ValidatorOptions = {
|
|
|
224
224
|
selectedOptionKeys?: string[];
|
|
225
225
|
globalUtilityGuard?: boolean;
|
|
226
226
|
policies?: DynamicRule[];
|
|
227
|
+
/**
|
|
228
|
+
* Global/base rate policy used by validation and service filtering.
|
|
229
|
+
* This is intentionally separate from fallbackSettings.ratePolicy.
|
|
230
|
+
*/
|
|
231
|
+
ratePolicy?: RatePolicy;
|
|
227
232
|
fallbackSettings?: FallbackSettings;
|
|
228
233
|
};
|
|
229
234
|
type RatePolicy = {
|
package/dist/workspace/index.cjs
CHANGED
|
@@ -4764,15 +4764,13 @@ function rateOk(svcMap, candidate, primary, policy) {
|
|
|
4764
4764
|
|
|
4765
4765
|
// src/core/validate/steps/rates.ts
|
|
4766
4766
|
function validateRates(v) {
|
|
4767
|
-
var _a, _b, _c
|
|
4768
|
-
const ratePolicy = normalizeRatePolicy(
|
|
4769
|
-
(_a = v.options.fallbackSettings) == null ? void 0 : _a.ratePolicy
|
|
4770
|
-
);
|
|
4767
|
+
var _a, _b, _c;
|
|
4768
|
+
const ratePolicy = normalizeRatePolicy(v.options.ratePolicy);
|
|
4771
4769
|
for (const f of v.fields) {
|
|
4772
4770
|
if (!isMultiField(f)) continue;
|
|
4773
4771
|
const baseRates = [];
|
|
4774
|
-
for (const o of (
|
|
4775
|
-
const role = (
|
|
4772
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
4773
|
+
const role = (_c = (_b = o.pricing_role) != null ? _b : f.pricing_role) != null ? _c : "base";
|
|
4776
4774
|
if (role !== "base") continue;
|
|
4777
4775
|
const sid = o.service_id;
|
|
4778
4776
|
if (!isServiceIdRef(sid)) continue;
|
|
@@ -5546,6 +5544,38 @@ function applyPolicies(errors, props, serviceMap, policies, fieldsVisibleUnder,
|
|
|
5546
5544
|
}
|
|
5547
5545
|
}
|
|
5548
5546
|
|
|
5547
|
+
// src/core/governance.ts
|
|
5548
|
+
var DEFAULT_FALLBACK_SETTINGS = {
|
|
5549
|
+
requireConstraintFit: true,
|
|
5550
|
+
ratePolicy: { kind: "lte_primary", pct: 5 },
|
|
5551
|
+
selectionStrategy: "priority",
|
|
5552
|
+
mode: "strict"
|
|
5553
|
+
};
|
|
5554
|
+
function resolveGlobalRatePolicy(options) {
|
|
5555
|
+
return normalizeRatePolicy(options.ratePolicy);
|
|
5556
|
+
}
|
|
5557
|
+
function resolveFallbackSettings(options) {
|
|
5558
|
+
var _a;
|
|
5559
|
+
return {
|
|
5560
|
+
...DEFAULT_FALLBACK_SETTINGS,
|
|
5561
|
+
...(_a = options.fallbackSettings) != null ? _a : {}
|
|
5562
|
+
};
|
|
5563
|
+
}
|
|
5564
|
+
function mergeValidatorOptions(defaults = {}, overrides = {}) {
|
|
5565
|
+
var _a, _b, _c, _d;
|
|
5566
|
+
const mergedFallbackSettings = {
|
|
5567
|
+
...(_a = defaults.fallbackSettings) != null ? _a : {},
|
|
5568
|
+
...(_b = overrides.fallbackSettings) != null ? _b : {}
|
|
5569
|
+
};
|
|
5570
|
+
return {
|
|
5571
|
+
...defaults,
|
|
5572
|
+
...overrides,
|
|
5573
|
+
policies: (_c = overrides.policies) != null ? _c : defaults.policies,
|
|
5574
|
+
ratePolicy: (_d = overrides.ratePolicy) != null ? _d : defaults.ratePolicy,
|
|
5575
|
+
fallbackSettings: Object.keys(mergedFallbackSettings).length > 0 ? mergedFallbackSettings : void 0
|
|
5576
|
+
};
|
|
5577
|
+
}
|
|
5578
|
+
|
|
5549
5579
|
// src/core/builder.ts
|
|
5550
5580
|
var import_lodash_es2 = require("lodash-es");
|
|
5551
5581
|
function createBuilder(opts = {}) {
|
|
@@ -5788,7 +5818,7 @@ var BuilderImpl = class {
|
|
|
5788
5818
|
return out;
|
|
5789
5819
|
}
|
|
5790
5820
|
errors() {
|
|
5791
|
-
return validate(this.props, this.options);
|
|
5821
|
+
return validate(this.props, mergeValidatorOptions({}, this.options));
|
|
5792
5822
|
}
|
|
5793
5823
|
getOptions() {
|
|
5794
5824
|
return (0, import_lodash_es2.cloneDeep)(this.options);
|
|
@@ -6075,11 +6105,14 @@ function readVisibilitySimOpts(ctx) {
|
|
|
6075
6105
|
};
|
|
6076
6106
|
}
|
|
6077
6107
|
function validate(props, ctx = {}) {
|
|
6078
|
-
var _a, _b, _c
|
|
6108
|
+
var _a, _b, _c;
|
|
6109
|
+
const options = mergeValidatorOptions({}, ctx);
|
|
6110
|
+
const fallbackSettings = resolveFallbackSettings(options);
|
|
6111
|
+
const ratePolicy = resolveGlobalRatePolicy(options);
|
|
6079
6112
|
const errors = [];
|
|
6080
|
-
const serviceMap = (_a =
|
|
6113
|
+
const serviceMap = (_a = options.serviceMap) != null ? _a : {};
|
|
6081
6114
|
const selectedKeys = new Set(
|
|
6082
|
-
(_b =
|
|
6115
|
+
(_b = options.selectedOptionKeys) != null ? _b : []
|
|
6083
6116
|
);
|
|
6084
6117
|
const tags = Array.isArray(props.filters) ? props.filters : [];
|
|
6085
6118
|
const fields = Array.isArray(props.fields) ? props.fields : [];
|
|
@@ -6089,8 +6122,12 @@ function validate(props, ctx = {}) {
|
|
|
6089
6122
|
for (const f of fields) fieldById.set(f.id, f);
|
|
6090
6123
|
const v = {
|
|
6091
6124
|
props,
|
|
6092
|
-
nodeMap: (_c =
|
|
6093
|
-
options:
|
|
6125
|
+
nodeMap: (_c = options.nodeMap) != null ? _c : buildNodeMap(props),
|
|
6126
|
+
options: {
|
|
6127
|
+
...options,
|
|
6128
|
+
ratePolicy,
|
|
6129
|
+
fallbackSettings
|
|
6130
|
+
},
|
|
6094
6131
|
errors,
|
|
6095
6132
|
serviceMap,
|
|
6096
6133
|
selectedKeys,
|
|
@@ -6105,7 +6142,7 @@ function validate(props, ctx = {}) {
|
|
|
6105
6142
|
validateIdentity(v);
|
|
6106
6143
|
validateOptionMaps(v);
|
|
6107
6144
|
v.fieldsVisibleUnder = createFieldsVisibleUnder(v);
|
|
6108
|
-
const visSim = readVisibilitySimOpts(
|
|
6145
|
+
const visSim = readVisibilitySimOpts(options);
|
|
6109
6146
|
validateVisibility(v, visSim);
|
|
6110
6147
|
applyPolicies(
|
|
6111
6148
|
v.errors,
|
|
@@ -6126,7 +6163,7 @@ function validate(props, ctx = {}) {
|
|
|
6126
6163
|
builder,
|
|
6127
6164
|
services: serviceMap,
|
|
6128
6165
|
tagId: tag.id,
|
|
6129
|
-
ratePolicy
|
|
6166
|
+
ratePolicy,
|
|
6130
6167
|
invalidFieldIds: v.invalidRateFieldIds
|
|
6131
6168
|
});
|
|
6132
6169
|
for (const diag of diags) {
|
|
@@ -6695,18 +6732,23 @@ function createNodeIndex(builder) {
|
|
|
6695
6732
|
|
|
6696
6733
|
// src/core/service-filter.ts
|
|
6697
6734
|
function filterServicesForVisibleGroup(input, deps) {
|
|
6698
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6735
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6699
6736
|
const svcMap = (_c = (_b = (_a = deps.builder).getServiceMap) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
6737
|
+
const builderOptions = (_e = (_d = deps.builder).getOptions) == null ? void 0 : _e.call(_d);
|
|
6700
6738
|
const { context } = input;
|
|
6701
6739
|
const usedSet = new Set(context.usedServiceIds.map(String));
|
|
6702
6740
|
const primary = context.usedServiceIds[0];
|
|
6741
|
+
const explicitFallbackSettings = (_f = context.fallbackSettings) != null ? _f : context.fallback;
|
|
6742
|
+
const resolvedRatePolicy = normalizeRatePolicy(
|
|
6743
|
+
(_h = (_g = context.ratePolicy) != null ? _g : explicitFallbackSettings == null ? void 0 : explicitFallbackSettings.ratePolicy) != null ? _h : builderOptions == null ? void 0 : builderOptions.ratePolicy
|
|
6744
|
+
);
|
|
6745
|
+
const fallbackSettingsSource = explicitFallbackSettings != null ? explicitFallbackSettings : builderOptions == null ? void 0 : builderOptions.fallbackSettings;
|
|
6703
6746
|
const fb = {
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
mode: "strict",
|
|
6708
|
-
...(_d = context.fallback) != null ? _d : {}
|
|
6747
|
+
...DEFAULT_FALLBACK_SETTINGS,
|
|
6748
|
+
...fallbackSettingsSource != null ? fallbackSettingsSource : {},
|
|
6749
|
+
ratePolicy: resolvedRatePolicy
|
|
6709
6750
|
};
|
|
6751
|
+
const policySource = (_j = (_i = context.policies) != null ? _i : builderOptions == null ? void 0 : builderOptions.policies) != null ? _j : [];
|
|
6710
6752
|
const visibleServiceIds = context.selectedButtons === void 0 ? void 0 : collectVisibleServiceIds(
|
|
6711
6753
|
deps.builder,
|
|
6712
6754
|
context.tagId,
|
|
@@ -6731,11 +6773,11 @@ function filterServicesForVisibleGroup(input, deps) {
|
|
|
6731
6773
|
const fitsConstraints = constraintFitOk(
|
|
6732
6774
|
svcMap,
|
|
6733
6775
|
cap.id,
|
|
6734
|
-
(
|
|
6776
|
+
(_k = context.effectiveConstraints) != null ? _k : {}
|
|
6735
6777
|
);
|
|
6736
6778
|
const passesRate2 = primary == null ? true : rateOk(svcMap, id, primary, fb);
|
|
6737
6779
|
const polRes = evaluatePoliciesRaw(
|
|
6738
|
-
|
|
6780
|
+
policySource,
|
|
6739
6781
|
[...context.usedServiceIds, id],
|
|
6740
6782
|
svcMap,
|
|
6741
6783
|
context.tagId,
|
|
@@ -8419,6 +8461,8 @@ function filterServicesForVisibleGroup2(ctx, candidates, input) {
|
|
|
8419
8461
|
usedServiceIds: input.usedServiceIds,
|
|
8420
8462
|
effectiveConstraints: input.effectiveConstraints,
|
|
8421
8463
|
policies: input.policies,
|
|
8464
|
+
ratePolicy: input.ratePolicy,
|
|
8465
|
+
fallbackSettings: input.fallbackSettings,
|
|
8422
8466
|
fallback: input.fallback
|
|
8423
8467
|
}
|
|
8424
8468
|
};
|
|
@@ -9840,6 +9884,8 @@ function CanvasProviderWorkspaceRuntime({
|
|
|
9840
9884
|
children,
|
|
9841
9885
|
builderOpts,
|
|
9842
9886
|
canvasOpts,
|
|
9887
|
+
ratePolicy,
|
|
9888
|
+
fallbackSettings,
|
|
9843
9889
|
attachToWorkspace = true
|
|
9844
9890
|
}) {
|
|
9845
9891
|
const ws = useWorkspaceMaybe();
|
|
@@ -9858,11 +9904,23 @@ function CanvasProviderWorkspaceRuntime({
|
|
|
9858
9904
|
const resolvedBuilderOpts = (0, import_react2.useMemo)(() => {
|
|
9859
9905
|
const svc = ws.services.data;
|
|
9860
9906
|
const hasMap = svc != null && typeof svc === "object" && !Array.isArray(svc);
|
|
9861
|
-
|
|
9907
|
+
const policies = ws.policies.policies.data;
|
|
9908
|
+
return {
|
|
9862
9909
|
...builderOpts != null ? builderOpts : {},
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
|
|
9910
|
+
...hasMap ? {
|
|
9911
|
+
serviceMap: svc
|
|
9912
|
+
} : {},
|
|
9913
|
+
policies: policies != null ? policies : void 0,
|
|
9914
|
+
ratePolicy: ratePolicy != null ? ratePolicy : builderOpts == null ? void 0 : builderOpts.ratePolicy,
|
|
9915
|
+
fallbackSettings: fallbackSettings != null ? fallbackSettings : builderOpts == null ? void 0 : builderOpts.fallbackSettings
|
|
9916
|
+
};
|
|
9917
|
+
}, [
|
|
9918
|
+
builderOpts,
|
|
9919
|
+
fallbackSettings,
|
|
9920
|
+
ratePolicy,
|
|
9921
|
+
ws.policies.policies.data,
|
|
9922
|
+
ws.services.data
|
|
9923
|
+
]);
|
|
9866
9924
|
if (canMountCanvas) {
|
|
9867
9925
|
hasMountedOnceRef.current = true;
|
|
9868
9926
|
}
|
|
@@ -10200,7 +10258,7 @@ function useCanvasOwned(initialProps, canvasOpts, builderOpts) {
|
|
|
10200
10258
|
} else if (((_a = window.SITE) == null ? void 0 : _a.env) !== "production") {
|
|
10201
10259
|
if (builderOptsRef.current !== builderOpts) {
|
|
10202
10260
|
console.warn(
|
|
10203
|
-
"[useCanvasOwned] builderOpts changed after init
|
|
10261
|
+
"[useCanvasOwned] builderOpts changed after init. Reactive keys (serviceMap/policies/ratePolicy/fallbackSettings/selectedOptionKeys) are applied via setOptions(); other keys may still require remounting to fully reinitialize."
|
|
10204
10262
|
);
|
|
10205
10263
|
builderOptsRef.current = builderOpts;
|
|
10206
10264
|
}
|
|
@@ -10212,6 +10270,23 @@ function useCanvasOwned(initialProps, canvasOpts, builderOpts) {
|
|
|
10212
10270
|
loadedOnceRef.current = true;
|
|
10213
10271
|
}
|
|
10214
10272
|
}, [initialProps]);
|
|
10273
|
+
(0, import_react2.useEffect)(() => {
|
|
10274
|
+
if (!builderOpts) return;
|
|
10275
|
+
builder.setOptions({
|
|
10276
|
+
serviceMap: builderOpts.serviceMap,
|
|
10277
|
+
policies: builderOpts.policies,
|
|
10278
|
+
ratePolicy: builderOpts.ratePolicy,
|
|
10279
|
+
fallbackSettings: builderOpts.fallbackSettings,
|
|
10280
|
+
selectedOptionKeys: builderOpts.selectedOptionKeys
|
|
10281
|
+
});
|
|
10282
|
+
}, [
|
|
10283
|
+
builder,
|
|
10284
|
+
builderOpts == null ? void 0 : builderOpts.fallbackSettings,
|
|
10285
|
+
builderOpts == null ? void 0 : builderOpts.policies,
|
|
10286
|
+
builderOpts == null ? void 0 : builderOpts.ratePolicy,
|
|
10287
|
+
builderOpts == null ? void 0 : builderOpts.selectedOptionKeys,
|
|
10288
|
+
builderOpts == null ? void 0 : builderOpts.serviceMap
|
|
10289
|
+
]);
|
|
10215
10290
|
const lastCanvasOptsRef = (0, import_react2.useRef)();
|
|
10216
10291
|
const stableCanvasOpts = (0, import_react2.useMemo)(() => {
|
|
10217
10292
|
var _a2;
|
|
@@ -10537,18 +10612,18 @@ function useErrors(opts = {}) {
|
|
|
10537
10612
|
setValidating(true);
|
|
10538
10613
|
schedule(
|
|
10539
10614
|
() => {
|
|
10540
|
-
var _a2, _b2;
|
|
10615
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
10541
10616
|
if (token !== runTokenRef.current) return;
|
|
10542
10617
|
try {
|
|
10543
10618
|
const props = api.editor.getProps();
|
|
10544
|
-
const res = validate(props);
|
|
10619
|
+
const res = validate(props, (_c2 = (_b2 = (_a2 = api.builder).getOptions) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : {});
|
|
10545
10620
|
if (token !== runTokenRef.current) return;
|
|
10546
10621
|
setValidation(toValidationRows(res != null ? res : []));
|
|
10547
10622
|
} catch (err) {
|
|
10548
10623
|
if (token !== runTokenRef.current) return;
|
|
10549
10624
|
pushLog({
|
|
10550
|
-
message: (
|
|
10551
|
-
code: (
|
|
10625
|
+
message: (_d2 = err == null ? void 0 : err.message) != null ? _d2 : "validate() threw",
|
|
10626
|
+
code: (_e2 = err == null ? void 0 : err.code) != null ? _e2 : "validate_throw",
|
|
10552
10627
|
meta: err
|
|
10553
10628
|
});
|
|
10554
10629
|
setValidation([]);
|
|
@@ -12010,6 +12085,8 @@ function Workspace(props) {
|
|
|
12010
12085
|
liveDebounceMs,
|
|
12011
12086
|
autosaveMs,
|
|
12012
12087
|
autoAutosave,
|
|
12088
|
+
ratePolicy,
|
|
12089
|
+
fallbackSettings,
|
|
12013
12090
|
tools,
|
|
12014
12091
|
children
|
|
12015
12092
|
} = props;
|
|
@@ -12025,7 +12102,14 @@ function Workspace(props) {
|
|
|
12025
12102
|
liveDebounceMs,
|
|
12026
12103
|
autosaveMs,
|
|
12027
12104
|
autoAutosave,
|
|
12028
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
12105
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
12106
|
+
CanvasProvider,
|
|
12107
|
+
{
|
|
12108
|
+
ratePolicy,
|
|
12109
|
+
fallbackSettings,
|
|
12110
|
+
children: children(tools)
|
|
12111
|
+
}
|
|
12112
|
+
)
|
|
12029
12113
|
}
|
|
12030
12114
|
);
|
|
12031
12115
|
}
|