@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
|
@@ -112,6 +112,11 @@ type ValidatorOptions = {
|
|
|
112
112
|
selectedOptionKeys?: string[];
|
|
113
113
|
globalUtilityGuard?: boolean;
|
|
114
114
|
policies?: DynamicRule[];
|
|
115
|
+
/**
|
|
116
|
+
* Global/base rate policy used by validation and service filtering.
|
|
117
|
+
* This is intentionally separate from fallbackSettings.ratePolicy.
|
|
118
|
+
*/
|
|
119
|
+
ratePolicy?: RatePolicy;
|
|
115
120
|
fallbackSettings?: FallbackSettings;
|
|
116
121
|
};
|
|
117
122
|
type RatePolicy = {
|
|
@@ -380,6 +385,7 @@ interface Builder {
|
|
|
380
385
|
getProps(): ServiceProps;
|
|
381
386
|
/** Service map for validation/rules */
|
|
382
387
|
getServiceMap(): DgpServiceMap;
|
|
388
|
+
getOptions(): BuilderOptions;
|
|
383
389
|
getConstraints(): {
|
|
384
390
|
id: string;
|
|
385
391
|
label: string;
|
|
@@ -1832,6 +1838,9 @@ declare class Editor {
|
|
|
1832
1838
|
usedServiceIds: Array<number | string>;
|
|
1833
1839
|
effectiveConstraints?: Partial<Record<"refill" | "cancel" | "dripfeed", boolean>>;
|
|
1834
1840
|
policies?: unknown;
|
|
1841
|
+
ratePolicy?: RatePolicy;
|
|
1842
|
+
fallbackSettings?: FallbackSettings;
|
|
1843
|
+
/** Backward-compatible alias */
|
|
1835
1844
|
fallback?: FallbackSettings;
|
|
1836
1845
|
}): ServiceCheck[];
|
|
1837
1846
|
private moduleCtx;
|
|
@@ -1908,6 +1917,8 @@ type CanvasProviderWorkspaceProps = {
|
|
|
1908
1917
|
children: ReactNode;
|
|
1909
1918
|
builderOpts?: BuilderOptions;
|
|
1910
1919
|
canvasOpts?: CanvasOptions & CanvasBackendOptions;
|
|
1920
|
+
ratePolicy?: RatePolicy;
|
|
1921
|
+
fallbackSettings?: FallbackSettings;
|
|
1911
1922
|
attachToWorkspace?: boolean;
|
|
1912
1923
|
};
|
|
1913
1924
|
type CanvasProviderProps = CanvasProviderManagedProps | CanvasProviderWorkspaceProps;
|
|
@@ -2244,6 +2255,10 @@ interface WorkspaceProps {
|
|
|
2244
2255
|
readonly autosaveMs?: WorkspaceProviderProps["autosaveMs"];
|
|
2245
2256
|
/** Auto-run autosave when dirty (default true) */
|
|
2246
2257
|
readonly autoAutosave?: WorkspaceProviderProps["autoAutosave"];
|
|
2258
|
+
/** Global/base rate policy (separate from fallbackSettings.ratePolicy). */
|
|
2259
|
+
readonly ratePolicy?: RatePolicy;
|
|
2260
|
+
/** Fallback flow settings. */
|
|
2261
|
+
readonly fallbackSettings?: FallbackSettings;
|
|
2247
2262
|
readonly tools?: ToolsConfig;
|
|
2248
2263
|
readonly children: (tools?: ToolsConfig) => React.ReactNode;
|
|
2249
2264
|
}
|
|
@@ -112,6 +112,11 @@ type ValidatorOptions = {
|
|
|
112
112
|
selectedOptionKeys?: string[];
|
|
113
113
|
globalUtilityGuard?: boolean;
|
|
114
114
|
policies?: DynamicRule[];
|
|
115
|
+
/**
|
|
116
|
+
* Global/base rate policy used by validation and service filtering.
|
|
117
|
+
* This is intentionally separate from fallbackSettings.ratePolicy.
|
|
118
|
+
*/
|
|
119
|
+
ratePolicy?: RatePolicy;
|
|
115
120
|
fallbackSettings?: FallbackSettings;
|
|
116
121
|
};
|
|
117
122
|
type RatePolicy = {
|
|
@@ -380,6 +385,7 @@ interface Builder {
|
|
|
380
385
|
getProps(): ServiceProps;
|
|
381
386
|
/** Service map for validation/rules */
|
|
382
387
|
getServiceMap(): DgpServiceMap;
|
|
388
|
+
getOptions(): BuilderOptions;
|
|
383
389
|
getConstraints(): {
|
|
384
390
|
id: string;
|
|
385
391
|
label: string;
|
|
@@ -1832,6 +1838,9 @@ declare class Editor {
|
|
|
1832
1838
|
usedServiceIds: Array<number | string>;
|
|
1833
1839
|
effectiveConstraints?: Partial<Record<"refill" | "cancel" | "dripfeed", boolean>>;
|
|
1834
1840
|
policies?: unknown;
|
|
1841
|
+
ratePolicy?: RatePolicy;
|
|
1842
|
+
fallbackSettings?: FallbackSettings;
|
|
1843
|
+
/** Backward-compatible alias */
|
|
1835
1844
|
fallback?: FallbackSettings;
|
|
1836
1845
|
}): ServiceCheck[];
|
|
1837
1846
|
private moduleCtx;
|
|
@@ -1908,6 +1917,8 @@ type CanvasProviderWorkspaceProps = {
|
|
|
1908
1917
|
children: ReactNode;
|
|
1909
1918
|
builderOpts?: BuilderOptions;
|
|
1910
1919
|
canvasOpts?: CanvasOptions & CanvasBackendOptions;
|
|
1920
|
+
ratePolicy?: RatePolicy;
|
|
1921
|
+
fallbackSettings?: FallbackSettings;
|
|
1911
1922
|
attachToWorkspace?: boolean;
|
|
1912
1923
|
};
|
|
1913
1924
|
type CanvasProviderProps = CanvasProviderManagedProps | CanvasProviderWorkspaceProps;
|
|
@@ -2244,6 +2255,10 @@ interface WorkspaceProps {
|
|
|
2244
2255
|
readonly autosaveMs?: WorkspaceProviderProps["autosaveMs"];
|
|
2245
2256
|
/** Auto-run autosave when dirty (default true) */
|
|
2246
2257
|
readonly autoAutosave?: WorkspaceProviderProps["autoAutosave"];
|
|
2258
|
+
/** Global/base rate policy (separate from fallbackSettings.ratePolicy). */
|
|
2259
|
+
readonly ratePolicy?: RatePolicy;
|
|
2260
|
+
/** Fallback flow settings. */
|
|
2261
|
+
readonly fallbackSettings?: FallbackSettings;
|
|
2247
2262
|
readonly tools?: ToolsConfig;
|
|
2248
2263
|
readonly children: (tools?: ToolsConfig) => React.ReactNode;
|
|
2249
2264
|
}
|
package/dist/workspace/index.js
CHANGED
|
@@ -4721,15 +4721,13 @@ function rateOk(svcMap, candidate, primary, policy) {
|
|
|
4721
4721
|
|
|
4722
4722
|
// src/core/validate/steps/rates.ts
|
|
4723
4723
|
function validateRates(v) {
|
|
4724
|
-
var _a, _b, _c
|
|
4725
|
-
const ratePolicy = normalizeRatePolicy(
|
|
4726
|
-
(_a = v.options.fallbackSettings) == null ? void 0 : _a.ratePolicy
|
|
4727
|
-
);
|
|
4724
|
+
var _a, _b, _c;
|
|
4725
|
+
const ratePolicy = normalizeRatePolicy(v.options.ratePolicy);
|
|
4728
4726
|
for (const f of v.fields) {
|
|
4729
4727
|
if (!isMultiField(f)) continue;
|
|
4730
4728
|
const baseRates = [];
|
|
4731
|
-
for (const o of (
|
|
4732
|
-
const role = (
|
|
4729
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
4730
|
+
const role = (_c = (_b = o.pricing_role) != null ? _b : f.pricing_role) != null ? _c : "base";
|
|
4733
4731
|
if (role !== "base") continue;
|
|
4734
4732
|
const sid = o.service_id;
|
|
4735
4733
|
if (!isServiceIdRef(sid)) continue;
|
|
@@ -5503,6 +5501,38 @@ function applyPolicies(errors, props, serviceMap, policies, fieldsVisibleUnder,
|
|
|
5503
5501
|
}
|
|
5504
5502
|
}
|
|
5505
5503
|
|
|
5504
|
+
// src/core/governance.ts
|
|
5505
|
+
var DEFAULT_FALLBACK_SETTINGS = {
|
|
5506
|
+
requireConstraintFit: true,
|
|
5507
|
+
ratePolicy: { kind: "lte_primary", pct: 5 },
|
|
5508
|
+
selectionStrategy: "priority",
|
|
5509
|
+
mode: "strict"
|
|
5510
|
+
};
|
|
5511
|
+
function resolveGlobalRatePolicy(options) {
|
|
5512
|
+
return normalizeRatePolicy(options.ratePolicy);
|
|
5513
|
+
}
|
|
5514
|
+
function resolveFallbackSettings(options) {
|
|
5515
|
+
var _a;
|
|
5516
|
+
return {
|
|
5517
|
+
...DEFAULT_FALLBACK_SETTINGS,
|
|
5518
|
+
...(_a = options.fallbackSettings) != null ? _a : {}
|
|
5519
|
+
};
|
|
5520
|
+
}
|
|
5521
|
+
function mergeValidatorOptions(defaults = {}, overrides = {}) {
|
|
5522
|
+
var _a, _b, _c, _d;
|
|
5523
|
+
const mergedFallbackSettings = {
|
|
5524
|
+
...(_a = defaults.fallbackSettings) != null ? _a : {},
|
|
5525
|
+
...(_b = overrides.fallbackSettings) != null ? _b : {}
|
|
5526
|
+
};
|
|
5527
|
+
return {
|
|
5528
|
+
...defaults,
|
|
5529
|
+
...overrides,
|
|
5530
|
+
policies: (_c = overrides.policies) != null ? _c : defaults.policies,
|
|
5531
|
+
ratePolicy: (_d = overrides.ratePolicy) != null ? _d : defaults.ratePolicy,
|
|
5532
|
+
fallbackSettings: Object.keys(mergedFallbackSettings).length > 0 ? mergedFallbackSettings : void 0
|
|
5533
|
+
};
|
|
5534
|
+
}
|
|
5535
|
+
|
|
5506
5536
|
// src/core/builder.ts
|
|
5507
5537
|
import { cloneDeep as cloneDeep2 } from "lodash-es";
|
|
5508
5538
|
function createBuilder(opts = {}) {
|
|
@@ -5745,7 +5775,7 @@ var BuilderImpl = class {
|
|
|
5745
5775
|
return out;
|
|
5746
5776
|
}
|
|
5747
5777
|
errors() {
|
|
5748
|
-
return validate(this.props, this.options);
|
|
5778
|
+
return validate(this.props, mergeValidatorOptions({}, this.options));
|
|
5749
5779
|
}
|
|
5750
5780
|
getOptions() {
|
|
5751
5781
|
return cloneDeep2(this.options);
|
|
@@ -6032,11 +6062,14 @@ function readVisibilitySimOpts(ctx) {
|
|
|
6032
6062
|
};
|
|
6033
6063
|
}
|
|
6034
6064
|
function validate(props, ctx = {}) {
|
|
6035
|
-
var _a, _b, _c
|
|
6065
|
+
var _a, _b, _c;
|
|
6066
|
+
const options = mergeValidatorOptions({}, ctx);
|
|
6067
|
+
const fallbackSettings = resolveFallbackSettings(options);
|
|
6068
|
+
const ratePolicy = resolveGlobalRatePolicy(options);
|
|
6036
6069
|
const errors = [];
|
|
6037
|
-
const serviceMap = (_a =
|
|
6070
|
+
const serviceMap = (_a = options.serviceMap) != null ? _a : {};
|
|
6038
6071
|
const selectedKeys = new Set(
|
|
6039
|
-
(_b =
|
|
6072
|
+
(_b = options.selectedOptionKeys) != null ? _b : []
|
|
6040
6073
|
);
|
|
6041
6074
|
const tags = Array.isArray(props.filters) ? props.filters : [];
|
|
6042
6075
|
const fields = Array.isArray(props.fields) ? props.fields : [];
|
|
@@ -6046,8 +6079,12 @@ function validate(props, ctx = {}) {
|
|
|
6046
6079
|
for (const f of fields) fieldById.set(f.id, f);
|
|
6047
6080
|
const v = {
|
|
6048
6081
|
props,
|
|
6049
|
-
nodeMap: (_c =
|
|
6050
|
-
options:
|
|
6082
|
+
nodeMap: (_c = options.nodeMap) != null ? _c : buildNodeMap(props),
|
|
6083
|
+
options: {
|
|
6084
|
+
...options,
|
|
6085
|
+
ratePolicy,
|
|
6086
|
+
fallbackSettings
|
|
6087
|
+
},
|
|
6051
6088
|
errors,
|
|
6052
6089
|
serviceMap,
|
|
6053
6090
|
selectedKeys,
|
|
@@ -6062,7 +6099,7 @@ function validate(props, ctx = {}) {
|
|
|
6062
6099
|
validateIdentity(v);
|
|
6063
6100
|
validateOptionMaps(v);
|
|
6064
6101
|
v.fieldsVisibleUnder = createFieldsVisibleUnder(v);
|
|
6065
|
-
const visSim = readVisibilitySimOpts(
|
|
6102
|
+
const visSim = readVisibilitySimOpts(options);
|
|
6066
6103
|
validateVisibility(v, visSim);
|
|
6067
6104
|
applyPolicies(
|
|
6068
6105
|
v.errors,
|
|
@@ -6083,7 +6120,7 @@ function validate(props, ctx = {}) {
|
|
|
6083
6120
|
builder,
|
|
6084
6121
|
services: serviceMap,
|
|
6085
6122
|
tagId: tag.id,
|
|
6086
|
-
ratePolicy
|
|
6123
|
+
ratePolicy,
|
|
6087
6124
|
invalidFieldIds: v.invalidRateFieldIds
|
|
6088
6125
|
});
|
|
6089
6126
|
for (const diag of diags) {
|
|
@@ -6652,18 +6689,23 @@ function createNodeIndex(builder) {
|
|
|
6652
6689
|
|
|
6653
6690
|
// src/core/service-filter.ts
|
|
6654
6691
|
function filterServicesForVisibleGroup(input, deps) {
|
|
6655
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6692
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6656
6693
|
const svcMap = (_c = (_b = (_a = deps.builder).getServiceMap) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
6694
|
+
const builderOptions = (_e = (_d = deps.builder).getOptions) == null ? void 0 : _e.call(_d);
|
|
6657
6695
|
const { context } = input;
|
|
6658
6696
|
const usedSet = new Set(context.usedServiceIds.map(String));
|
|
6659
6697
|
const primary = context.usedServiceIds[0];
|
|
6698
|
+
const explicitFallbackSettings = (_f = context.fallbackSettings) != null ? _f : context.fallback;
|
|
6699
|
+
const resolvedRatePolicy = normalizeRatePolicy(
|
|
6700
|
+
(_h = (_g = context.ratePolicy) != null ? _g : explicitFallbackSettings == null ? void 0 : explicitFallbackSettings.ratePolicy) != null ? _h : builderOptions == null ? void 0 : builderOptions.ratePolicy
|
|
6701
|
+
);
|
|
6702
|
+
const fallbackSettingsSource = explicitFallbackSettings != null ? explicitFallbackSettings : builderOptions == null ? void 0 : builderOptions.fallbackSettings;
|
|
6660
6703
|
const fb = {
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
mode: "strict",
|
|
6665
|
-
...(_d = context.fallback) != null ? _d : {}
|
|
6704
|
+
...DEFAULT_FALLBACK_SETTINGS,
|
|
6705
|
+
...fallbackSettingsSource != null ? fallbackSettingsSource : {},
|
|
6706
|
+
ratePolicy: resolvedRatePolicy
|
|
6666
6707
|
};
|
|
6708
|
+
const policySource = (_j = (_i = context.policies) != null ? _i : builderOptions == null ? void 0 : builderOptions.policies) != null ? _j : [];
|
|
6667
6709
|
const visibleServiceIds = context.selectedButtons === void 0 ? void 0 : collectVisibleServiceIds(
|
|
6668
6710
|
deps.builder,
|
|
6669
6711
|
context.tagId,
|
|
@@ -6688,11 +6730,11 @@ function filterServicesForVisibleGroup(input, deps) {
|
|
|
6688
6730
|
const fitsConstraints = constraintFitOk(
|
|
6689
6731
|
svcMap,
|
|
6690
6732
|
cap.id,
|
|
6691
|
-
(
|
|
6733
|
+
(_k = context.effectiveConstraints) != null ? _k : {}
|
|
6692
6734
|
);
|
|
6693
6735
|
const passesRate2 = primary == null ? true : rateOk(svcMap, id, primary, fb);
|
|
6694
6736
|
const polRes = evaluatePoliciesRaw(
|
|
6695
|
-
|
|
6737
|
+
policySource,
|
|
6696
6738
|
[...context.usedServiceIds, id],
|
|
6697
6739
|
svcMap,
|
|
6698
6740
|
context.tagId,
|
|
@@ -8376,6 +8418,8 @@ function filterServicesForVisibleGroup2(ctx, candidates, input) {
|
|
|
8376
8418
|
usedServiceIds: input.usedServiceIds,
|
|
8377
8419
|
effectiveConstraints: input.effectiveConstraints,
|
|
8378
8420
|
policies: input.policies,
|
|
8421
|
+
ratePolicy: input.ratePolicy,
|
|
8422
|
+
fallbackSettings: input.fallbackSettings,
|
|
8379
8423
|
fallback: input.fallback
|
|
8380
8424
|
}
|
|
8381
8425
|
};
|
|
@@ -9797,6 +9841,8 @@ function CanvasProviderWorkspaceRuntime({
|
|
|
9797
9841
|
children,
|
|
9798
9842
|
builderOpts,
|
|
9799
9843
|
canvasOpts,
|
|
9844
|
+
ratePolicy,
|
|
9845
|
+
fallbackSettings,
|
|
9800
9846
|
attachToWorkspace = true
|
|
9801
9847
|
}) {
|
|
9802
9848
|
const ws = useWorkspaceMaybe();
|
|
@@ -9815,11 +9861,23 @@ function CanvasProviderWorkspaceRuntime({
|
|
|
9815
9861
|
const resolvedBuilderOpts = useMemo13(() => {
|
|
9816
9862
|
const svc = ws.services.data;
|
|
9817
9863
|
const hasMap = svc != null && typeof svc === "object" && !Array.isArray(svc);
|
|
9818
|
-
|
|
9864
|
+
const policies = ws.policies.policies.data;
|
|
9865
|
+
return {
|
|
9819
9866
|
...builderOpts != null ? builderOpts : {},
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9867
|
+
...hasMap ? {
|
|
9868
|
+
serviceMap: svc
|
|
9869
|
+
} : {},
|
|
9870
|
+
policies: policies != null ? policies : void 0,
|
|
9871
|
+
ratePolicy: ratePolicy != null ? ratePolicy : builderOpts == null ? void 0 : builderOpts.ratePolicy,
|
|
9872
|
+
fallbackSettings: fallbackSettings != null ? fallbackSettings : builderOpts == null ? void 0 : builderOpts.fallbackSettings
|
|
9873
|
+
};
|
|
9874
|
+
}, [
|
|
9875
|
+
builderOpts,
|
|
9876
|
+
fallbackSettings,
|
|
9877
|
+
ratePolicy,
|
|
9878
|
+
ws.policies.policies.data,
|
|
9879
|
+
ws.services.data
|
|
9880
|
+
]);
|
|
9823
9881
|
if (canMountCanvas) {
|
|
9824
9882
|
hasMountedOnceRef.current = true;
|
|
9825
9883
|
}
|
|
@@ -9893,68 +9951,43 @@ function useCanvasFromExisting(api) {
|
|
|
9893
9951
|
}
|
|
9894
9952
|
var NO_SNAPSHOT_HYDRATION_KEY = "__no_snapshot__";
|
|
9895
9953
|
function useHydrateEditorSnapshot(api, snapshot) {
|
|
9896
|
-
const
|
|
9954
|
+
const fallbackIdentityRef = useRef6(
|
|
9955
|
+
`snapshot:fallback:${Math.random().toString(36).slice(2)}`
|
|
9956
|
+
);
|
|
9957
|
+
const hydratedIdentityRef = useRef6(NO_SNAPSHOT_HYDRATION_KEY);
|
|
9958
|
+
const [hydrationReady, setHydrationReady] = useState11(false);
|
|
9959
|
+
const targetHydrationIdentity = useMemo13(() => {
|
|
9897
9960
|
if (!(snapshot == null ? void 0 : snapshot.props)) return NO_SNAPSHOT_HYDRATION_KEY;
|
|
9898
|
-
return
|
|
9961
|
+
return getSnapshotHydrationIdentity(snapshot, fallbackIdentityRef.current);
|
|
9899
9962
|
}, [snapshot]);
|
|
9900
|
-
const [hydratedKey, setHydratedKey] = useState11(
|
|
9901
|
-
NO_SNAPSHOT_HYDRATION_KEY
|
|
9902
|
-
);
|
|
9903
9963
|
useLayoutEffect(() => {
|
|
9904
|
-
if (hydratedKey === targetHydrationKey) return;
|
|
9905
9964
|
if (snapshot == null ? void 0 : snapshot.props) {
|
|
9906
|
-
|
|
9965
|
+
const shouldHydrate = hydratedIdentityRef.current !== targetHydrationIdentity;
|
|
9966
|
+
if (shouldHydrate) {
|
|
9967
|
+
hydrateEditorFromSnapshot(api, snapshot);
|
|
9968
|
+
hydratedIdentityRef.current = targetHydrationIdentity;
|
|
9969
|
+
}
|
|
9907
9970
|
}
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9971
|
+
if (!hydrationReady) {
|
|
9972
|
+
setHydrationReady(true);
|
|
9973
|
+
}
|
|
9974
|
+
}, [api, hydrationReady, snapshot, targetHydrationIdentity]);
|
|
9975
|
+
return hydrationReady;
|
|
9911
9976
|
}
|
|
9912
|
-
function
|
|
9913
|
-
var _a, _b, _c
|
|
9977
|
+
function getSnapshotHydrationIdentity(snapshot, fallbackIdentity) {
|
|
9978
|
+
var _a, _b, _c;
|
|
9914
9979
|
const meta = snapshot.meta;
|
|
9915
|
-
const
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
const catalogKey = serializeForHydration(snapshot.catalog);
|
|
9925
|
-
return [
|
|
9926
|
-
metaKey,
|
|
9927
|
-
String(((_i = (_h = snapshot.props) == null ? void 0 : _h.fields) != null ? _i : []).length),
|
|
9928
|
-
String(((_k = (_j = snapshot.props) == null ? void 0 : _j.filters) != null ? _k : []).length),
|
|
9929
|
-
positionKeys,
|
|
9930
|
-
viewport,
|
|
9931
|
-
selection,
|
|
9932
|
-
catalogKey
|
|
9933
|
-
].join("::");
|
|
9934
|
-
}
|
|
9935
|
-
function serializeForHydration(value) {
|
|
9936
|
-
if (value == null) return "";
|
|
9937
|
-
try {
|
|
9938
|
-
return JSON.stringify(sortForHydration(value));
|
|
9939
|
-
} catch {
|
|
9940
|
-
return "__unserializable__";
|
|
9941
|
-
}
|
|
9942
|
-
}
|
|
9943
|
-
function sortForHydration(value) {
|
|
9944
|
-
if (Array.isArray(value)) {
|
|
9945
|
-
return value.map((entry) => sortForHydration(entry));
|
|
9946
|
-
}
|
|
9947
|
-
if (value && typeof value === "object") {
|
|
9948
|
-
const entries = Object.entries(value).sort(
|
|
9949
|
-
([a], [b]) => a.localeCompare(b)
|
|
9950
|
-
);
|
|
9951
|
-
const next = {};
|
|
9952
|
-
for (const [key, entry] of entries) {
|
|
9953
|
-
next[key] = sortForHydration(entry);
|
|
9954
|
-
}
|
|
9955
|
-
return next;
|
|
9980
|
+
const snapshotId = (_a = meta == null ? void 0 : meta.snapshot_id) != null ? _a : meta == null ? void 0 : meta.snapshotId;
|
|
9981
|
+
const versionId = (_b = meta == null ? void 0 : meta.version_id) != null ? _b : meta == null ? void 0 : meta.versionId;
|
|
9982
|
+
const branchId = (_c = meta == null ? void 0 : meta.branch_id) != null ? _c : meta == null ? void 0 : meta.branchId;
|
|
9983
|
+
if (snapshotId != null || versionId != null || branchId != null) {
|
|
9984
|
+
return [
|
|
9985
|
+
String(snapshotId != null ? snapshotId : ""),
|
|
9986
|
+
String(versionId != null ? versionId : ""),
|
|
9987
|
+
String(branchId != null ? branchId : "")
|
|
9988
|
+
].join("|");
|
|
9956
9989
|
}
|
|
9957
|
-
return
|
|
9990
|
+
return fallbackIdentity;
|
|
9958
9991
|
}
|
|
9959
9992
|
function hydrateEditorFromSnapshot(api, snapshot) {
|
|
9960
9993
|
var _a;
|
|
@@ -10182,7 +10215,7 @@ function useCanvasOwned(initialProps, canvasOpts, builderOpts) {
|
|
|
10182
10215
|
} else if (((_a = window.SITE) == null ? void 0 : _a.env) !== "production") {
|
|
10183
10216
|
if (builderOptsRef.current !== builderOpts) {
|
|
10184
10217
|
console.warn(
|
|
10185
|
-
"[useCanvasOwned] builderOpts changed after init
|
|
10218
|
+
"[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."
|
|
10186
10219
|
);
|
|
10187
10220
|
builderOptsRef.current = builderOpts;
|
|
10188
10221
|
}
|
|
@@ -10194,6 +10227,23 @@ function useCanvasOwned(initialProps, canvasOpts, builderOpts) {
|
|
|
10194
10227
|
loadedOnceRef.current = true;
|
|
10195
10228
|
}
|
|
10196
10229
|
}, [initialProps]);
|
|
10230
|
+
useEffect7(() => {
|
|
10231
|
+
if (!builderOpts) return;
|
|
10232
|
+
builder.setOptions({
|
|
10233
|
+
serviceMap: builderOpts.serviceMap,
|
|
10234
|
+
policies: builderOpts.policies,
|
|
10235
|
+
ratePolicy: builderOpts.ratePolicy,
|
|
10236
|
+
fallbackSettings: builderOpts.fallbackSettings,
|
|
10237
|
+
selectedOptionKeys: builderOpts.selectedOptionKeys
|
|
10238
|
+
});
|
|
10239
|
+
}, [
|
|
10240
|
+
builder,
|
|
10241
|
+
builderOpts == null ? void 0 : builderOpts.fallbackSettings,
|
|
10242
|
+
builderOpts == null ? void 0 : builderOpts.policies,
|
|
10243
|
+
builderOpts == null ? void 0 : builderOpts.ratePolicy,
|
|
10244
|
+
builderOpts == null ? void 0 : builderOpts.selectedOptionKeys,
|
|
10245
|
+
builderOpts == null ? void 0 : builderOpts.serviceMap
|
|
10246
|
+
]);
|
|
10197
10247
|
const lastCanvasOptsRef = useRef6();
|
|
10198
10248
|
const stableCanvasOpts = useMemo13(() => {
|
|
10199
10249
|
var _a2;
|
|
@@ -10519,18 +10569,18 @@ function useErrors(opts = {}) {
|
|
|
10519
10569
|
setValidating(true);
|
|
10520
10570
|
schedule(
|
|
10521
10571
|
() => {
|
|
10522
|
-
var _a2, _b2;
|
|
10572
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
10523
10573
|
if (token !== runTokenRef.current) return;
|
|
10524
10574
|
try {
|
|
10525
10575
|
const props = api.editor.getProps();
|
|
10526
|
-
const res = validate(props);
|
|
10576
|
+
const res = validate(props, (_c2 = (_b2 = (_a2 = api.builder).getOptions) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : {});
|
|
10527
10577
|
if (token !== runTokenRef.current) return;
|
|
10528
10578
|
setValidation(toValidationRows(res != null ? res : []));
|
|
10529
10579
|
} catch (err) {
|
|
10530
10580
|
if (token !== runTokenRef.current) return;
|
|
10531
10581
|
pushLog({
|
|
10532
|
-
message: (
|
|
10533
|
-
code: (
|
|
10582
|
+
message: (_d2 = err == null ? void 0 : err.message) != null ? _d2 : "validate() threw",
|
|
10583
|
+
code: (_e2 = err == null ? void 0 : err.code) != null ? _e2 : "validate_throw",
|
|
10534
10584
|
meta: err
|
|
10535
10585
|
});
|
|
10536
10586
|
setValidation([]);
|
|
@@ -11992,6 +12042,8 @@ function Workspace(props) {
|
|
|
11992
12042
|
liveDebounceMs,
|
|
11993
12043
|
autosaveMs,
|
|
11994
12044
|
autoAutosave,
|
|
12045
|
+
ratePolicy,
|
|
12046
|
+
fallbackSettings,
|
|
11995
12047
|
tools,
|
|
11996
12048
|
children
|
|
11997
12049
|
} = props;
|
|
@@ -12007,7 +12059,14 @@ function Workspace(props) {
|
|
|
12007
12059
|
liveDebounceMs,
|
|
12008
12060
|
autosaveMs,
|
|
12009
12061
|
autoAutosave,
|
|
12010
|
-
children: /* @__PURE__ */ jsx3(
|
|
12062
|
+
children: /* @__PURE__ */ jsx3(
|
|
12063
|
+
CanvasProvider,
|
|
12064
|
+
{
|
|
12065
|
+
ratePolicy,
|
|
12066
|
+
fallbackSettings,
|
|
12067
|
+
children: children(tools)
|
|
12068
|
+
}
|
|
12069
|
+
)
|
|
12011
12070
|
}
|
|
12012
12071
|
);
|
|
12013
12072
|
}
|