@timeax/digital-service-engine 0.1.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 +145 -86
- 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 +145 -86
- package/dist/workspace/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.cjs
CHANGED
|
@@ -1289,15 +1289,13 @@ function rateOk(svcMap, candidate, primary, policy) {
|
|
|
1289
1289
|
|
|
1290
1290
|
// src/core/validate/steps/rates.ts
|
|
1291
1291
|
function validateRates(v) {
|
|
1292
|
-
var _a, _b, _c
|
|
1293
|
-
const ratePolicy = normalizeRatePolicy(
|
|
1294
|
-
(_a = v.options.fallbackSettings) == null ? void 0 : _a.ratePolicy
|
|
1295
|
-
);
|
|
1292
|
+
var _a, _b, _c;
|
|
1293
|
+
const ratePolicy = normalizeRatePolicy(v.options.ratePolicy);
|
|
1296
1294
|
for (const f of v.fields) {
|
|
1297
1295
|
if (!isMultiField(f)) continue;
|
|
1298
1296
|
const baseRates = [];
|
|
1299
|
-
for (const o of (
|
|
1300
|
-
const role = (
|
|
1297
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
1298
|
+
const role = (_c = (_b = o.pricing_role) != null ? _b : f.pricing_role) != null ? _c : "base";
|
|
1301
1299
|
if (role !== "base") continue;
|
|
1302
1300
|
const sid = o.service_id;
|
|
1303
1301
|
if (!isServiceIdRef(sid)) continue;
|
|
@@ -2071,6 +2069,38 @@ function applyPolicies(errors, props, serviceMap, policies, fieldsVisibleUnder,
|
|
|
2071
2069
|
}
|
|
2072
2070
|
}
|
|
2073
2071
|
|
|
2072
|
+
// src/core/governance.ts
|
|
2073
|
+
var DEFAULT_FALLBACK_SETTINGS = {
|
|
2074
|
+
requireConstraintFit: true,
|
|
2075
|
+
ratePolicy: { kind: "lte_primary", pct: 5 },
|
|
2076
|
+
selectionStrategy: "priority",
|
|
2077
|
+
mode: "strict"
|
|
2078
|
+
};
|
|
2079
|
+
function resolveGlobalRatePolicy(options) {
|
|
2080
|
+
return normalizeRatePolicy(options.ratePolicy);
|
|
2081
|
+
}
|
|
2082
|
+
function resolveFallbackSettings(options) {
|
|
2083
|
+
var _a;
|
|
2084
|
+
return {
|
|
2085
|
+
...DEFAULT_FALLBACK_SETTINGS,
|
|
2086
|
+
...(_a = options.fallbackSettings) != null ? _a : {}
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
function mergeValidatorOptions(defaults = {}, overrides = {}) {
|
|
2090
|
+
var _a, _b, _c, _d;
|
|
2091
|
+
const mergedFallbackSettings = {
|
|
2092
|
+
...(_a = defaults.fallbackSettings) != null ? _a : {},
|
|
2093
|
+
...(_b = overrides.fallbackSettings) != null ? _b : {}
|
|
2094
|
+
};
|
|
2095
|
+
return {
|
|
2096
|
+
...defaults,
|
|
2097
|
+
...overrides,
|
|
2098
|
+
policies: (_c = overrides.policies) != null ? _c : defaults.policies,
|
|
2099
|
+
ratePolicy: (_d = overrides.ratePolicy) != null ? _d : defaults.ratePolicy,
|
|
2100
|
+
fallbackSettings: Object.keys(mergedFallbackSettings).length > 0 ? mergedFallbackSettings : void 0
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2074
2104
|
// src/core/builder.ts
|
|
2075
2105
|
var import_lodash_es2 = require("lodash-es");
|
|
2076
2106
|
function createBuilder(opts = {}) {
|
|
@@ -2313,7 +2343,7 @@ var BuilderImpl = class {
|
|
|
2313
2343
|
return out;
|
|
2314
2344
|
}
|
|
2315
2345
|
errors() {
|
|
2316
|
-
return validate(this.props, this.options);
|
|
2346
|
+
return validate(this.props, mergeValidatorOptions({}, this.options));
|
|
2317
2347
|
}
|
|
2318
2348
|
getOptions() {
|
|
2319
2349
|
return (0, import_lodash_es2.cloneDeep)(this.options);
|
|
@@ -2600,11 +2630,14 @@ function readVisibilitySimOpts(ctx) {
|
|
|
2600
2630
|
};
|
|
2601
2631
|
}
|
|
2602
2632
|
function validate(props, ctx = {}) {
|
|
2603
|
-
var _a, _b, _c
|
|
2633
|
+
var _a, _b, _c;
|
|
2634
|
+
const options = mergeValidatorOptions({}, ctx);
|
|
2635
|
+
const fallbackSettings = resolveFallbackSettings(options);
|
|
2636
|
+
const ratePolicy = resolveGlobalRatePolicy(options);
|
|
2604
2637
|
const errors = [];
|
|
2605
|
-
const serviceMap = (_a =
|
|
2638
|
+
const serviceMap = (_a = options.serviceMap) != null ? _a : {};
|
|
2606
2639
|
const selectedKeys = new Set(
|
|
2607
|
-
(_b =
|
|
2640
|
+
(_b = options.selectedOptionKeys) != null ? _b : []
|
|
2608
2641
|
);
|
|
2609
2642
|
const tags = Array.isArray(props.filters) ? props.filters : [];
|
|
2610
2643
|
const fields = Array.isArray(props.fields) ? props.fields : [];
|
|
@@ -2614,8 +2647,12 @@ function validate(props, ctx = {}) {
|
|
|
2614
2647
|
for (const f of fields) fieldById.set(f.id, f);
|
|
2615
2648
|
const v = {
|
|
2616
2649
|
props,
|
|
2617
|
-
nodeMap: (_c =
|
|
2618
|
-
options:
|
|
2650
|
+
nodeMap: (_c = options.nodeMap) != null ? _c : buildNodeMap(props),
|
|
2651
|
+
options: {
|
|
2652
|
+
...options,
|
|
2653
|
+
ratePolicy,
|
|
2654
|
+
fallbackSettings
|
|
2655
|
+
},
|
|
2619
2656
|
errors,
|
|
2620
2657
|
serviceMap,
|
|
2621
2658
|
selectedKeys,
|
|
@@ -2630,7 +2667,7 @@ function validate(props, ctx = {}) {
|
|
|
2630
2667
|
validateIdentity(v);
|
|
2631
2668
|
validateOptionMaps(v);
|
|
2632
2669
|
v.fieldsVisibleUnder = createFieldsVisibleUnder(v);
|
|
2633
|
-
const visSim = readVisibilitySimOpts(
|
|
2670
|
+
const visSim = readVisibilitySimOpts(options);
|
|
2634
2671
|
validateVisibility(v, visSim);
|
|
2635
2672
|
applyPolicies(
|
|
2636
2673
|
v.errors,
|
|
@@ -2651,7 +2688,7 @@ function validate(props, ctx = {}) {
|
|
|
2651
2688
|
builder,
|
|
2652
2689
|
services: serviceMap,
|
|
2653
2690
|
tagId: tag.id,
|
|
2654
|
-
ratePolicy
|
|
2691
|
+
ratePolicy,
|
|
2655
2692
|
invalidFieldIds: v.invalidRateFieldIds
|
|
2656
2693
|
});
|
|
2657
2694
|
for (const diag of diags) {
|
|
@@ -3562,18 +3599,23 @@ function compilePolicies(raw) {
|
|
|
3562
3599
|
|
|
3563
3600
|
// src/core/service-filter.ts
|
|
3564
3601
|
function filterServicesForVisibleGroup(input, deps) {
|
|
3565
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3602
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3566
3603
|
const svcMap = (_c = (_b = (_a = deps.builder).getServiceMap) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
3604
|
+
const builderOptions = (_e = (_d = deps.builder).getOptions) == null ? void 0 : _e.call(_d);
|
|
3567
3605
|
const { context } = input;
|
|
3568
3606
|
const usedSet = new Set(context.usedServiceIds.map(String));
|
|
3569
3607
|
const primary = context.usedServiceIds[0];
|
|
3608
|
+
const explicitFallbackSettings = (_f = context.fallbackSettings) != null ? _f : context.fallback;
|
|
3609
|
+
const resolvedRatePolicy = normalizeRatePolicy(
|
|
3610
|
+
(_h = (_g = context.ratePolicy) != null ? _g : explicitFallbackSettings == null ? void 0 : explicitFallbackSettings.ratePolicy) != null ? _h : builderOptions == null ? void 0 : builderOptions.ratePolicy
|
|
3611
|
+
);
|
|
3612
|
+
const fallbackSettingsSource = explicitFallbackSettings != null ? explicitFallbackSettings : builderOptions == null ? void 0 : builderOptions.fallbackSettings;
|
|
3570
3613
|
const fb = {
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
mode: "strict",
|
|
3575
|
-
...(_d = context.fallback) != null ? _d : {}
|
|
3614
|
+
...DEFAULT_FALLBACK_SETTINGS,
|
|
3615
|
+
...fallbackSettingsSource != null ? fallbackSettingsSource : {},
|
|
3616
|
+
ratePolicy: resolvedRatePolicy
|
|
3576
3617
|
};
|
|
3618
|
+
const policySource = (_j = (_i = context.policies) != null ? _i : builderOptions == null ? void 0 : builderOptions.policies) != null ? _j : [];
|
|
3577
3619
|
const visibleServiceIds = context.selectedButtons === void 0 ? void 0 : collectVisibleServiceIds(
|
|
3578
3620
|
deps.builder,
|
|
3579
3621
|
context.tagId,
|
|
@@ -3598,11 +3640,11 @@ function filterServicesForVisibleGroup(input, deps) {
|
|
|
3598
3640
|
const fitsConstraints = constraintFitOk(
|
|
3599
3641
|
svcMap,
|
|
3600
3642
|
cap.id,
|
|
3601
|
-
(
|
|
3643
|
+
(_k = context.effectiveConstraints) != null ? _k : {}
|
|
3602
3644
|
);
|
|
3603
3645
|
const passesRate2 = primary == null ? true : rateOk(svcMap, id, primary, fb);
|
|
3604
3646
|
const polRes = evaluatePoliciesRaw(
|
|
3605
|
-
|
|
3647
|
+
policySource,
|
|
3606
3648
|
[...context.usedServiceIds, id],
|
|
3607
3649
|
svcMap,
|
|
3608
3650
|
context.tagId,
|