@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/react/index.d.cts
CHANGED
|
@@ -234,6 +234,11 @@ type ValidatorOptions = {
|
|
|
234
234
|
selectedOptionKeys?: string[];
|
|
235
235
|
globalUtilityGuard?: boolean;
|
|
236
236
|
policies?: DynamicRule[];
|
|
237
|
+
/**
|
|
238
|
+
* Global/base rate policy used by validation and service filtering.
|
|
239
|
+
* This is intentionally separate from fallbackSettings.ratePolicy.
|
|
240
|
+
*/
|
|
241
|
+
ratePolicy?: RatePolicy;
|
|
237
242
|
fallbackSettings?: FallbackSettings;
|
|
238
243
|
};
|
|
239
244
|
type RatePolicy = {
|
|
@@ -629,6 +634,7 @@ interface Builder {
|
|
|
629
634
|
getProps(): ServiceProps;
|
|
630
635
|
/** Service map for validation/rules */
|
|
631
636
|
getServiceMap(): DgpServiceMap;
|
|
637
|
+
getOptions(): BuilderOptions;
|
|
632
638
|
getConstraints(): {
|
|
633
639
|
id: string;
|
|
634
640
|
label: string;
|
|
@@ -1649,6 +1655,9 @@ declare class Editor {
|
|
|
1649
1655
|
usedServiceIds: Array<number | string>;
|
|
1650
1656
|
effectiveConstraints?: Partial<Record<"refill" | "cancel" | "dripfeed", boolean>>;
|
|
1651
1657
|
policies?: unknown;
|
|
1658
|
+
ratePolicy?: RatePolicy;
|
|
1659
|
+
fallbackSettings?: FallbackSettings;
|
|
1660
|
+
/** Backward-compatible alias */
|
|
1652
1661
|
fallback?: FallbackSettings;
|
|
1653
1662
|
}): ServiceCheck[];
|
|
1654
1663
|
private moduleCtx;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -234,6 +234,11 @@ type ValidatorOptions = {
|
|
|
234
234
|
selectedOptionKeys?: string[];
|
|
235
235
|
globalUtilityGuard?: boolean;
|
|
236
236
|
policies?: DynamicRule[];
|
|
237
|
+
/**
|
|
238
|
+
* Global/base rate policy used by validation and service filtering.
|
|
239
|
+
* This is intentionally separate from fallbackSettings.ratePolicy.
|
|
240
|
+
*/
|
|
241
|
+
ratePolicy?: RatePolicy;
|
|
237
242
|
fallbackSettings?: FallbackSettings;
|
|
238
243
|
};
|
|
239
244
|
type RatePolicy = {
|
|
@@ -629,6 +634,7 @@ interface Builder {
|
|
|
629
634
|
getProps(): ServiceProps;
|
|
630
635
|
/** Service map for validation/rules */
|
|
631
636
|
getServiceMap(): DgpServiceMap;
|
|
637
|
+
getOptions(): BuilderOptions;
|
|
632
638
|
getConstraints(): {
|
|
633
639
|
id: string;
|
|
634
640
|
label: string;
|
|
@@ -1649,6 +1655,9 @@ declare class Editor {
|
|
|
1649
1655
|
usedServiceIds: Array<number | string>;
|
|
1650
1656
|
effectiveConstraints?: Partial<Record<"refill" | "cancel" | "dripfeed", boolean>>;
|
|
1651
1657
|
policies?: unknown;
|
|
1658
|
+
ratePolicy?: RatePolicy;
|
|
1659
|
+
fallbackSettings?: FallbackSettings;
|
|
1660
|
+
/** Backward-compatible alias */
|
|
1652
1661
|
fallback?: FallbackSettings;
|
|
1653
1662
|
}): ServiceCheck[];
|
|
1654
1663
|
private moduleCtx;
|
package/dist/react/index.js
CHANGED
|
@@ -1903,15 +1903,13 @@ function rateOk(svcMap, candidate, primary, policy) {
|
|
|
1903
1903
|
|
|
1904
1904
|
// src/core/validate/steps/rates.ts
|
|
1905
1905
|
function validateRates(v) {
|
|
1906
|
-
var _a, _b, _c
|
|
1907
|
-
const ratePolicy = normalizeRatePolicy(
|
|
1908
|
-
(_a = v.options.fallbackSettings) == null ? void 0 : _a.ratePolicy
|
|
1909
|
-
);
|
|
1906
|
+
var _a, _b, _c;
|
|
1907
|
+
const ratePolicy = normalizeRatePolicy(v.options.ratePolicy);
|
|
1910
1908
|
for (const f of v.fields) {
|
|
1911
1909
|
if (!isMultiField(f)) continue;
|
|
1912
1910
|
const baseRates = [];
|
|
1913
|
-
for (const o of (
|
|
1914
|
-
const role = (
|
|
1911
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
1912
|
+
const role = (_c = (_b = o.pricing_role) != null ? _b : f.pricing_role) != null ? _c : "base";
|
|
1915
1913
|
if (role !== "base") continue;
|
|
1916
1914
|
const sid = o.service_id;
|
|
1917
1915
|
if (!isServiceIdRef(sid)) continue;
|
|
@@ -2685,6 +2683,38 @@ function applyPolicies(errors, props, serviceMap, policies, fieldsVisibleUnder,
|
|
|
2685
2683
|
}
|
|
2686
2684
|
}
|
|
2687
2685
|
|
|
2686
|
+
// src/core/governance.ts
|
|
2687
|
+
var DEFAULT_FALLBACK_SETTINGS = {
|
|
2688
|
+
requireConstraintFit: true,
|
|
2689
|
+
ratePolicy: { kind: "lte_primary", pct: 5 },
|
|
2690
|
+
selectionStrategy: "priority",
|
|
2691
|
+
mode: "strict"
|
|
2692
|
+
};
|
|
2693
|
+
function resolveGlobalRatePolicy(options) {
|
|
2694
|
+
return normalizeRatePolicy(options.ratePolicy);
|
|
2695
|
+
}
|
|
2696
|
+
function resolveFallbackSettings(options) {
|
|
2697
|
+
var _a;
|
|
2698
|
+
return {
|
|
2699
|
+
...DEFAULT_FALLBACK_SETTINGS,
|
|
2700
|
+
...(_a = options.fallbackSettings) != null ? _a : {}
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2703
|
+
function mergeValidatorOptions(defaults = {}, overrides = {}) {
|
|
2704
|
+
var _a, _b, _c, _d;
|
|
2705
|
+
const mergedFallbackSettings = {
|
|
2706
|
+
...(_a = defaults.fallbackSettings) != null ? _a : {},
|
|
2707
|
+
...(_b = overrides.fallbackSettings) != null ? _b : {}
|
|
2708
|
+
};
|
|
2709
|
+
return {
|
|
2710
|
+
...defaults,
|
|
2711
|
+
...overrides,
|
|
2712
|
+
policies: (_c = overrides.policies) != null ? _c : defaults.policies,
|
|
2713
|
+
ratePolicy: (_d = overrides.ratePolicy) != null ? _d : defaults.ratePolicy,
|
|
2714
|
+
fallbackSettings: Object.keys(mergedFallbackSettings).length > 0 ? mergedFallbackSettings : void 0
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2688
2718
|
// src/core/builder.ts
|
|
2689
2719
|
import { cloneDeep as cloneDeep2 } from "lodash-es";
|
|
2690
2720
|
function createBuilder(opts = {}) {
|
|
@@ -2927,7 +2957,7 @@ var BuilderImpl = class {
|
|
|
2927
2957
|
return out;
|
|
2928
2958
|
}
|
|
2929
2959
|
errors() {
|
|
2930
|
-
return validate(this.props, this.options);
|
|
2960
|
+
return validate(this.props, mergeValidatorOptions({}, this.options));
|
|
2931
2961
|
}
|
|
2932
2962
|
getOptions() {
|
|
2933
2963
|
return cloneDeep2(this.options);
|
|
@@ -3214,11 +3244,14 @@ function readVisibilitySimOpts(ctx) {
|
|
|
3214
3244
|
};
|
|
3215
3245
|
}
|
|
3216
3246
|
function validate(props, ctx = {}) {
|
|
3217
|
-
var _a, _b, _c
|
|
3247
|
+
var _a, _b, _c;
|
|
3248
|
+
const options = mergeValidatorOptions({}, ctx);
|
|
3249
|
+
const fallbackSettings = resolveFallbackSettings(options);
|
|
3250
|
+
const ratePolicy = resolveGlobalRatePolicy(options);
|
|
3218
3251
|
const errors = [];
|
|
3219
|
-
const serviceMap = (_a =
|
|
3252
|
+
const serviceMap = (_a = options.serviceMap) != null ? _a : {};
|
|
3220
3253
|
const selectedKeys = new Set(
|
|
3221
|
-
(_b =
|
|
3254
|
+
(_b = options.selectedOptionKeys) != null ? _b : []
|
|
3222
3255
|
);
|
|
3223
3256
|
const tags = Array.isArray(props.filters) ? props.filters : [];
|
|
3224
3257
|
const fields = Array.isArray(props.fields) ? props.fields : [];
|
|
@@ -3228,8 +3261,12 @@ function validate(props, ctx = {}) {
|
|
|
3228
3261
|
for (const f of fields) fieldById.set(f.id, f);
|
|
3229
3262
|
const v = {
|
|
3230
3263
|
props,
|
|
3231
|
-
nodeMap: (_c =
|
|
3232
|
-
options:
|
|
3264
|
+
nodeMap: (_c = options.nodeMap) != null ? _c : buildNodeMap(props),
|
|
3265
|
+
options: {
|
|
3266
|
+
...options,
|
|
3267
|
+
ratePolicy,
|
|
3268
|
+
fallbackSettings
|
|
3269
|
+
},
|
|
3233
3270
|
errors,
|
|
3234
3271
|
serviceMap,
|
|
3235
3272
|
selectedKeys,
|
|
@@ -3244,7 +3281,7 @@ function validate(props, ctx = {}) {
|
|
|
3244
3281
|
validateIdentity(v);
|
|
3245
3282
|
validateOptionMaps(v);
|
|
3246
3283
|
v.fieldsVisibleUnder = createFieldsVisibleUnder(v);
|
|
3247
|
-
const visSim = readVisibilitySimOpts(
|
|
3284
|
+
const visSim = readVisibilitySimOpts(options);
|
|
3248
3285
|
validateVisibility(v, visSim);
|
|
3249
3286
|
applyPolicies(
|
|
3250
3287
|
v.errors,
|
|
@@ -3265,7 +3302,7 @@ function validate(props, ctx = {}) {
|
|
|
3265
3302
|
builder,
|
|
3266
3303
|
services: serviceMap,
|
|
3267
3304
|
tagId: tag.id,
|
|
3268
|
-
ratePolicy
|
|
3305
|
+
ratePolicy,
|
|
3269
3306
|
invalidFieldIds: v.invalidRateFieldIds
|
|
3270
3307
|
});
|
|
3271
3308
|
for (const diag of diags) {
|
|
@@ -4139,18 +4176,23 @@ function compilePolicies(raw) {
|
|
|
4139
4176
|
|
|
4140
4177
|
// src/core/service-filter.ts
|
|
4141
4178
|
function filterServicesForVisibleGroup(input, deps) {
|
|
4142
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4179
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4143
4180
|
const svcMap = (_c = (_b = (_a = deps.builder).getServiceMap) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
4181
|
+
const builderOptions = (_e = (_d = deps.builder).getOptions) == null ? void 0 : _e.call(_d);
|
|
4144
4182
|
const { context } = input;
|
|
4145
4183
|
const usedSet = new Set(context.usedServiceIds.map(String));
|
|
4146
4184
|
const primary = context.usedServiceIds[0];
|
|
4185
|
+
const explicitFallbackSettings = (_f = context.fallbackSettings) != null ? _f : context.fallback;
|
|
4186
|
+
const resolvedRatePolicy = normalizeRatePolicy(
|
|
4187
|
+
(_h = (_g = context.ratePolicy) != null ? _g : explicitFallbackSettings == null ? void 0 : explicitFallbackSettings.ratePolicy) != null ? _h : builderOptions == null ? void 0 : builderOptions.ratePolicy
|
|
4188
|
+
);
|
|
4189
|
+
const fallbackSettingsSource = explicitFallbackSettings != null ? explicitFallbackSettings : builderOptions == null ? void 0 : builderOptions.fallbackSettings;
|
|
4147
4190
|
const fb = {
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
mode: "strict",
|
|
4152
|
-
...(_d = context.fallback) != null ? _d : {}
|
|
4191
|
+
...DEFAULT_FALLBACK_SETTINGS,
|
|
4192
|
+
...fallbackSettingsSource != null ? fallbackSettingsSource : {},
|
|
4193
|
+
ratePolicy: resolvedRatePolicy
|
|
4153
4194
|
};
|
|
4195
|
+
const policySource = (_j = (_i = context.policies) != null ? _i : builderOptions == null ? void 0 : builderOptions.policies) != null ? _j : [];
|
|
4154
4196
|
const visibleServiceIds = context.selectedButtons === void 0 ? void 0 : collectVisibleServiceIds(
|
|
4155
4197
|
deps.builder,
|
|
4156
4198
|
context.tagId,
|
|
@@ -4175,11 +4217,11 @@ function filterServicesForVisibleGroup(input, deps) {
|
|
|
4175
4217
|
const fitsConstraints = constraintFitOk(
|
|
4176
4218
|
svcMap,
|
|
4177
4219
|
cap.id,
|
|
4178
|
-
(
|
|
4220
|
+
(_k = context.effectiveConstraints) != null ? _k : {}
|
|
4179
4221
|
);
|
|
4180
4222
|
const passesRate2 = primary == null ? true : rateOk(svcMap, id, primary, fb);
|
|
4181
4223
|
const polRes = evaluatePoliciesRaw(
|
|
4182
|
-
|
|
4224
|
+
policySource,
|
|
4183
4225
|
[...context.usedServiceIds, id],
|
|
4184
4226
|
svcMap,
|
|
4185
4227
|
context.tagId,
|
|
@@ -6923,6 +6965,8 @@ function filterServicesForVisibleGroup2(ctx, candidates, input) {
|
|
|
6923
6965
|
usedServiceIds: input.usedServiceIds,
|
|
6924
6966
|
effectiveConstraints: input.effectiveConstraints,
|
|
6925
6967
|
policies: input.policies,
|
|
6968
|
+
ratePolicy: input.ratePolicy,
|
|
6969
|
+
fallbackSettings: input.fallbackSettings,
|
|
6926
6970
|
fallback: input.fallback
|
|
6927
6971
|
}
|
|
6928
6972
|
};
|