@timeax/digital-service-engine 0.0.1 → 0.0.2
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 +1097 -193
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +189 -51
- package/dist/core/index.d.ts +189 -51
- package/dist/core/index.js +1095 -193
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +8313 -2542
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +401 -141
- package/dist/react/index.d.ts +401 -141
- package/dist/react/index.js +8471 -2709
- package/dist/react/index.js.map +1 -1
- package/dist/schema/index.d.cts +122 -54
- package/dist/schema/index.d.ts +122 -54
- package/dist/workspace/index.cjs +448 -239
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.d.cts +54 -50
- package/dist/workspace/index.d.ts +54 -50
- package/dist/workspace/index.js +448 -239
- package/dist/workspace/index.js.map +1 -1
- package/package.json +15 -6
- package/schema/editor-snapshot.schema.json +121 -209
- package/schema/service-props.schema.json +121 -209
package/dist/react/index.d.ts
CHANGED
|
@@ -34,12 +34,13 @@ interface BaseFieldUI {
|
|
|
34
34
|
name?: string;
|
|
35
35
|
label: string;
|
|
36
36
|
required?: boolean;
|
|
37
|
-
/** Host-defined prop names → typed UI nodes */
|
|
38
|
-
ui?: Record<string, Ui>;
|
|
39
37
|
/** Host-defined prop names → runtime default values (untyped base) */
|
|
40
38
|
defaults?: Record<string, unknown>;
|
|
41
39
|
}
|
|
42
|
-
type Ui = UiString | UiNumber | UiBoolean | UiAnyOf | UiArray | UiObject
|
|
40
|
+
type Ui = (UiString | UiNumber | UiBoolean | UiAnyOf | UiArray | UiObject) & {
|
|
41
|
+
description: string;
|
|
42
|
+
label: string;
|
|
43
|
+
};
|
|
43
44
|
/** string */
|
|
44
45
|
interface UiString {
|
|
45
46
|
type: "string";
|
|
@@ -74,8 +75,17 @@ interface UiAnyOf {
|
|
|
74
75
|
/** arrays: homogeneous (item) or tuple (items) */
|
|
75
76
|
interface UiArray {
|
|
76
77
|
type: "array";
|
|
78
|
+
label: string;
|
|
79
|
+
description: string;
|
|
77
80
|
item?: Ui;
|
|
78
81
|
items?: Ui[];
|
|
82
|
+
editable?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Optional: allowed shapes for new items.
|
|
85
|
+
* Key = label shown in UI picker
|
|
86
|
+
* Value = schema for the new element
|
|
87
|
+
*/
|
|
88
|
+
shape?: Record<string, Ui>;
|
|
79
89
|
minItems?: number;
|
|
80
90
|
maxItems?: number;
|
|
81
91
|
uniqueItems?: boolean;
|
|
@@ -83,7 +93,16 @@ interface UiArray {
|
|
|
83
93
|
/** objects: nested props */
|
|
84
94
|
interface UiObject {
|
|
85
95
|
type: "object";
|
|
96
|
+
label: string;
|
|
97
|
+
description: string;
|
|
98
|
+
editable?: boolean;
|
|
86
99
|
fields: Record<string, Ui>;
|
|
100
|
+
/**
|
|
101
|
+
* Optional: allowed shapes for dynamically added keys.
|
|
102
|
+
* Key = human-readable name shown in UI picker
|
|
103
|
+
* Value = schema applied to the value of the new key
|
|
104
|
+
*/
|
|
105
|
+
shape?: Record<string, Ui>;
|
|
87
106
|
required?: string[];
|
|
88
107
|
order?: string[];
|
|
89
108
|
}
|
|
@@ -192,6 +211,8 @@ type ServiceProps = {
|
|
|
192
211
|
excludes_for_buttons?: Record<string, string[]>;
|
|
193
212
|
schema_version?: string;
|
|
194
213
|
fallbacks?: ServiceFallback;
|
|
214
|
+
name?: string;
|
|
215
|
+
notices?: ServicePropsNotice[];
|
|
195
216
|
};
|
|
196
217
|
type ServiceIdRef = number | string;
|
|
197
218
|
type NodeIdRef = string;
|
|
@@ -201,6 +222,34 @@ type ServiceFallback = {
|
|
|
201
222
|
/** Primary→fallback list used when no node-scoped entry is present */
|
|
202
223
|
global?: Record<ServiceIdRef, ServiceIdRef[]>;
|
|
203
224
|
};
|
|
225
|
+
type NoticeType = "public" | "private";
|
|
226
|
+
type NoticeSeverity = "info" | "warning" | "error";
|
|
227
|
+
/**
|
|
228
|
+
* “label” is lightweight + UI-friendly (best, sale, hot, etc).
|
|
229
|
+
* Others remain semantic / governance oriented.
|
|
230
|
+
*/
|
|
231
|
+
type NoticeKind = "label" | "warning" | "deprecation" | "compat" | "migration" | "policy";
|
|
232
|
+
type NoticeTarget = {
|
|
233
|
+
scope: "global";
|
|
234
|
+
} | {
|
|
235
|
+
scope: "node";
|
|
236
|
+
node_kind: "tag" | "field" | "option";
|
|
237
|
+
node_id: string;
|
|
238
|
+
};
|
|
239
|
+
interface ServicePropsNotice {
|
|
240
|
+
id: string;
|
|
241
|
+
type: NoticeType;
|
|
242
|
+
kind: NoticeKind;
|
|
243
|
+
severity: NoticeSeverity;
|
|
244
|
+
target: NoticeTarget;
|
|
245
|
+
title: string;
|
|
246
|
+
description?: string;
|
|
247
|
+
reason?: string;
|
|
248
|
+
marked_at?: string;
|
|
249
|
+
icon?: string;
|
|
250
|
+
color?: string;
|
|
251
|
+
meta?: Record<string, unknown>;
|
|
252
|
+
}
|
|
204
253
|
|
|
205
254
|
type NodeKind = "tag" | "field" | "comment" | "option";
|
|
206
255
|
type EdgeKind = "child" | "bind" | "include" | "exclude" | "error" | "anchor";
|
|
@@ -440,6 +489,22 @@ type DgpServiceCapability = {
|
|
|
440
489
|
};
|
|
441
490
|
type DgpServiceMap = Record<string, DgpServiceCapability> & Record<number, DgpServiceCapability>;
|
|
442
491
|
|
|
492
|
+
type NodeRef$1 = {
|
|
493
|
+
kind: "tag";
|
|
494
|
+
id: string;
|
|
495
|
+
node: Tag;
|
|
496
|
+
} | {
|
|
497
|
+
kind: "field";
|
|
498
|
+
id: string;
|
|
499
|
+
node: Field;
|
|
500
|
+
} | {
|
|
501
|
+
kind: "option";
|
|
502
|
+
id: string;
|
|
503
|
+
node: FieldOption;
|
|
504
|
+
fieldId: string;
|
|
505
|
+
};
|
|
506
|
+
type NodeMap = Map<string, NodeRef$1>;
|
|
507
|
+
|
|
443
508
|
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" | "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";
|
|
444
509
|
type ValidationError = {
|
|
445
510
|
code: ValidationCode;
|
|
@@ -488,6 +553,7 @@ type DynamicRule = {
|
|
|
488
553
|
};
|
|
489
554
|
type ValidatorOptions = {
|
|
490
555
|
serviceMap?: DgpServiceMap;
|
|
556
|
+
nodeMap?: NodeMap;
|
|
491
557
|
allowUnsafe?: boolean;
|
|
492
558
|
selectedOptionKeys?: string[];
|
|
493
559
|
globalUtilityGuard?: boolean;
|
|
@@ -556,108 +622,12 @@ interface Builder {
|
|
|
556
622
|
description: string;
|
|
557
623
|
value: string;
|
|
558
624
|
}[];
|
|
625
|
+
isTagId(id: string): boolean;
|
|
626
|
+
isFieldId(id: string): boolean;
|
|
627
|
+
isOptionId(id: string): boolean;
|
|
628
|
+
getNodeMap(): NodeMap;
|
|
559
629
|
}
|
|
560
630
|
|
|
561
|
-
type Env = "client" | "workspace";
|
|
562
|
-
type VisibleGroup = {
|
|
563
|
-
tagId?: string;
|
|
564
|
-
tag?: Tag;
|
|
565
|
-
fields: Field[];
|
|
566
|
-
fieldIds: string[];
|
|
567
|
-
parentTags?: Tag[];
|
|
568
|
-
childrenTags?: Tag[];
|
|
569
|
-
/** In order of selection: tag base (unless overridden) then selected options */
|
|
570
|
-
services?: DgpServiceCapability[];
|
|
571
|
-
};
|
|
572
|
-
type VisibleGroupResult = {
|
|
573
|
-
kind: "single";
|
|
574
|
-
group: VisibleGroup;
|
|
575
|
-
} | {
|
|
576
|
-
kind: "multi";
|
|
577
|
-
groups: string[];
|
|
578
|
-
};
|
|
579
|
-
type ChangeEvt = {
|
|
580
|
-
ids: string[];
|
|
581
|
-
primary?: string;
|
|
582
|
-
};
|
|
583
|
-
type Listener = (e: ChangeEvt) => void;
|
|
584
|
-
type SelectionOptions = {
|
|
585
|
-
env?: Env;
|
|
586
|
-
rootTagId?: string;
|
|
587
|
-
/** Resolve service capability from an id (used for `services` array) */
|
|
588
|
-
resolveService?: (id: any) => DgpServiceCapability | undefined;
|
|
589
|
-
};
|
|
590
|
-
declare class Selection {
|
|
591
|
-
private readonly builder;
|
|
592
|
-
private readonly opts;
|
|
593
|
-
private set;
|
|
594
|
-
private primaryId;
|
|
595
|
-
private currentTagId;
|
|
596
|
-
private onChangeFns;
|
|
597
|
-
constructor(builder: Builder, opts: SelectionOptions);
|
|
598
|
-
replace(id?: string | null): void;
|
|
599
|
-
add(id: string): void;
|
|
600
|
-
remove(id: string): void;
|
|
601
|
-
toggle(id: string): void;
|
|
602
|
-
many(ids: Iterable<string>, primary?: string): void;
|
|
603
|
-
clear(): void;
|
|
604
|
-
all(): ReadonlySet<string>;
|
|
605
|
-
has(id: string): boolean;
|
|
606
|
-
primary(): string | undefined;
|
|
607
|
-
currentTag(): string | undefined;
|
|
608
|
-
onChange(fn: Listener): () => void;
|
|
609
|
-
visibleGroup(): VisibleGroupResult;
|
|
610
|
-
private emit;
|
|
611
|
-
private updateCurrentTagFrom;
|
|
612
|
-
private resolveTagContextId;
|
|
613
|
-
private selectedButtonTriggerIds;
|
|
614
|
-
private computeGroupForTag;
|
|
615
|
-
private addServiceByRole;
|
|
616
|
-
private findOptionById;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
type EditorEvents = {
|
|
620
|
-
"editor:command": {
|
|
621
|
-
name: string;
|
|
622
|
-
payload?: any;
|
|
623
|
-
};
|
|
624
|
-
"editor:change": {
|
|
625
|
-
props: ServiceProps;
|
|
626
|
-
reason: string;
|
|
627
|
-
command?: string;
|
|
628
|
-
};
|
|
629
|
-
"editor:undo": {
|
|
630
|
-
stackSize: number;
|
|
631
|
-
index: number;
|
|
632
|
-
};
|
|
633
|
-
"editor:redo": {
|
|
634
|
-
stackSize: number;
|
|
635
|
-
index: number;
|
|
636
|
-
};
|
|
637
|
-
"editor:error": {
|
|
638
|
-
message: string;
|
|
639
|
-
code?: string;
|
|
640
|
-
meta?: any;
|
|
641
|
-
};
|
|
642
|
-
};
|
|
643
|
-
type Command = {
|
|
644
|
-
name: string;
|
|
645
|
-
do(): void;
|
|
646
|
-
undo(): void;
|
|
647
|
-
};
|
|
648
|
-
type EditorOptions = {
|
|
649
|
-
historyLimit?: number;
|
|
650
|
-
validateAfterEach?: boolean;
|
|
651
|
-
/** Sync existence check; return true if the service exists. */
|
|
652
|
-
serviceExists?: (id: number) => boolean;
|
|
653
|
-
/** Optional local index; used if serviceExists is not provided. */
|
|
654
|
-
serviceMap?: Record<number, unknown>;
|
|
655
|
-
/** Raw policies JSON; will be compiled on demand by filterServicesForVisibleGroup. */
|
|
656
|
-
policiesRaw?: unknown;
|
|
657
|
-
selectionProps?: SelectionOptions;
|
|
658
|
-
};
|
|
659
|
-
type ConnectKind = "bind" | "include" | "exclude";
|
|
660
|
-
|
|
661
631
|
interface ButtonValue {
|
|
662
632
|
id: string;
|
|
663
633
|
value: string | number;
|
|
@@ -737,6 +707,8 @@ type OrderSnapshot = {
|
|
|
737
707
|
rule?: QuantityRule$1;
|
|
738
708
|
defaultedFromHost?: boolean;
|
|
739
709
|
};
|
|
710
|
+
min: number;
|
|
711
|
+
max: number;
|
|
740
712
|
services: Array<string | number>;
|
|
741
713
|
serviceMap: Record<string, Array<string | number>>;
|
|
742
714
|
fallbacks?: {
|
|
@@ -761,6 +733,106 @@ type OrderSnapshot = {
|
|
|
761
733
|
};
|
|
762
734
|
};
|
|
763
735
|
|
|
736
|
+
type Env = "client" | "workspace";
|
|
737
|
+
type VisibleGroup = {
|
|
738
|
+
tagId?: string;
|
|
739
|
+
tag?: Tag;
|
|
740
|
+
fields: Field[];
|
|
741
|
+
fieldIds: string[];
|
|
742
|
+
parentTags?: Tag[];
|
|
743
|
+
childrenTags?: Tag[];
|
|
744
|
+
/** In order of selection: tag base (unless overridden) then selected options */
|
|
745
|
+
services?: DgpServiceCapability[];
|
|
746
|
+
};
|
|
747
|
+
type VisibleGroupResult = {
|
|
748
|
+
kind: "single";
|
|
749
|
+
group: VisibleGroup;
|
|
750
|
+
} | {
|
|
751
|
+
kind: "multi";
|
|
752
|
+
groups: string[];
|
|
753
|
+
};
|
|
754
|
+
type ChangeEvt = {
|
|
755
|
+
ids: string[];
|
|
756
|
+
primary?: string;
|
|
757
|
+
};
|
|
758
|
+
type Listener = (e: ChangeEvt) => void;
|
|
759
|
+
type SelectionOptions = {
|
|
760
|
+
env?: Env;
|
|
761
|
+
rootTagId?: string;
|
|
762
|
+
/** Resolve service capability from an id (used for `services` array) */
|
|
763
|
+
resolveService?: (id: any) => DgpServiceCapability | undefined;
|
|
764
|
+
};
|
|
765
|
+
declare class Selection {
|
|
766
|
+
private readonly builder;
|
|
767
|
+
private readonly opts;
|
|
768
|
+
private set;
|
|
769
|
+
private primaryId;
|
|
770
|
+
private currentTagId;
|
|
771
|
+
private onChangeFns;
|
|
772
|
+
constructor(builder: Builder, opts: SelectionOptions);
|
|
773
|
+
replace(id?: string | null): void;
|
|
774
|
+
add(id: string): void;
|
|
775
|
+
remove(id: string): void;
|
|
776
|
+
toggle(id: string): void;
|
|
777
|
+
many(ids: Iterable<string>, primary?: string): void;
|
|
778
|
+
clear(): void;
|
|
779
|
+
all(): ReadonlySet<string>;
|
|
780
|
+
has(id: string): boolean;
|
|
781
|
+
primary(): string | undefined;
|
|
782
|
+
currentTag(): string | undefined;
|
|
783
|
+
onChange(fn: Listener): () => void;
|
|
784
|
+
visibleGroup(): VisibleGroupResult;
|
|
785
|
+
private emit;
|
|
786
|
+
private updateCurrentTagFrom;
|
|
787
|
+
private resolveTagContextId;
|
|
788
|
+
private selectedButtonTriggerIds;
|
|
789
|
+
private computeGroupForTag;
|
|
790
|
+
private addServiceByRole;
|
|
791
|
+
private findOptionById;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
type EditorEvents = {
|
|
795
|
+
"editor:command": {
|
|
796
|
+
name: string;
|
|
797
|
+
payload?: any;
|
|
798
|
+
};
|
|
799
|
+
"editor:change": {
|
|
800
|
+
props: ServiceProps;
|
|
801
|
+
reason: string;
|
|
802
|
+
command?: string;
|
|
803
|
+
};
|
|
804
|
+
"editor:undo": {
|
|
805
|
+
stackSize: number;
|
|
806
|
+
index: number;
|
|
807
|
+
};
|
|
808
|
+
"editor:redo": {
|
|
809
|
+
stackSize: number;
|
|
810
|
+
index: number;
|
|
811
|
+
};
|
|
812
|
+
"editor:error": {
|
|
813
|
+
message: string;
|
|
814
|
+
code?: string;
|
|
815
|
+
meta?: any;
|
|
816
|
+
};
|
|
817
|
+
};
|
|
818
|
+
type Command = {
|
|
819
|
+
name: string;
|
|
820
|
+
do(): void;
|
|
821
|
+
undo(): void;
|
|
822
|
+
};
|
|
823
|
+
type EditorOptions = {
|
|
824
|
+
historyLimit?: number;
|
|
825
|
+
validateAfterEach?: boolean;
|
|
826
|
+
/** Sync existence check; return true if the service exists. */
|
|
827
|
+
serviceExists?: (id: number) => boolean;
|
|
828
|
+
/** Optional local index; used if serviceExists is not provided. */
|
|
829
|
+
serviceMap?: Record<number, unknown>;
|
|
830
|
+
/** Raw policies JSON; will be compiled on demand by filterServicesForVisibleGroup. */
|
|
831
|
+
policiesRaw?: unknown;
|
|
832
|
+
selectionProps?: SelectionOptions;
|
|
833
|
+
};
|
|
834
|
+
type ConnectKind = "bind" | "include" | "exclude";
|
|
835
|
+
|
|
764
836
|
/** Exported alias so the schema generator can target an array */
|
|
765
837
|
type AdminPolicies = DynamicRule[];
|
|
766
838
|
|
|
@@ -1242,6 +1314,9 @@ declare class Editor {
|
|
|
1242
1314
|
private stagedBefore?;
|
|
1243
1315
|
private _lastPolicyDiagnostics?;
|
|
1244
1316
|
constructor(builder: Builder, api: CanvasAPI, opts?: EditorOptions);
|
|
1317
|
+
isTagId(id: string): boolean;
|
|
1318
|
+
isFieldId(id: string): boolean;
|
|
1319
|
+
isOptionId(id: string): boolean;
|
|
1245
1320
|
getProps(): ServiceProps;
|
|
1246
1321
|
transact(label: string, fn: () => void): void;
|
|
1247
1322
|
exec(cmd: Command): void;
|
|
@@ -1470,60 +1545,83 @@ declare class CanvasAPI {
|
|
|
1470
1545
|
getServiceProps(): ServiceProps;
|
|
1471
1546
|
}
|
|
1472
1547
|
|
|
1473
|
-
type
|
|
1474
|
-
|
|
1475
|
-
selections: Record<string, string[]>;
|
|
1476
|
-
};
|
|
1548
|
+
type Dict = Record<string, unknown>;
|
|
1549
|
+
type FormSnapshot = Dict;
|
|
1477
1550
|
type FormApi = {
|
|
1478
|
-
/**
|
|
1479
|
-
get: (fieldId: string) =>
|
|
1480
|
-
|
|
1481
|
-
|
|
1551
|
+
/** Value by fieldId (Wrapper uses name=field.id) */
|
|
1552
|
+
get: (fieldId: string) => unknown;
|
|
1553
|
+
/**
|
|
1554
|
+
* Programmatic set (NOT used by Wrapper).
|
|
1555
|
+
* If the field is mounted, writes into the core.
|
|
1556
|
+
* If not mounted, persists into core.bucket (via core.setValue) or local bag fallback.
|
|
1557
|
+
*/
|
|
1558
|
+
set: (fieldId: string, value: unknown) => void;
|
|
1559
|
+
/** Option selections (legacy; kept for compatibility) */
|
|
1482
1560
|
getSelections: (fieldId: string) => string[];
|
|
1483
1561
|
setSelections: (fieldId: string, optionIds: string[]) => void;
|
|
1484
1562
|
toggleSelection: (fieldId: string, optionId: string) => void;
|
|
1485
|
-
|
|
1563
|
+
removeSelectionToken(token: string): void;
|
|
1564
|
+
/** Read-only snapshot for debugging (NO validation) */
|
|
1486
1565
|
snapshot: () => FormSnapshot;
|
|
1487
1566
|
/** Simple subscribe (re-render triggers) */
|
|
1488
1567
|
subscribe: (fn: () => void) => () => void;
|
|
1568
|
+
/**
|
|
1569
|
+
* Validation gate:
|
|
1570
|
+
* local submit runs validation and returns mounted/visible values.
|
|
1571
|
+
* (This is NOT “submitting to a server”.)
|
|
1572
|
+
*/
|
|
1573
|
+
submit: () => {
|
|
1574
|
+
values: Dict;
|
|
1575
|
+
valid: boolean;
|
|
1576
|
+
};
|
|
1489
1577
|
};
|
|
1490
|
-
declare function FormProvider({ initial, children, }: {
|
|
1491
|
-
initial?: Partial<FormSnapshot>;
|
|
1492
|
-
children: ReactNode;
|
|
1493
|
-
}): react_jsx_runtime.JSX.Element;
|
|
1494
|
-
/** Strict hook (throws if no provider) */
|
|
1495
1578
|
declare function useFormApi(): FormApi;
|
|
1496
|
-
/** Optional hook (returns null if no provider) */
|
|
1497
1579
|
declare function useOptionalFormApi(): FormApi | null;
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1580
|
+
type FormProviderProps = {
|
|
1581
|
+
children: ReactNode;
|
|
1582
|
+
/** Optional schema (zod/jsonschema/etc, depending on your palette build) */
|
|
1583
|
+
schema?: any;
|
|
1584
|
+
/**
|
|
1585
|
+
* Same shape as the old OrderFlowProvider usage.
|
|
1586
|
+
* - values: seed values (persisted/rehydrated)
|
|
1587
|
+
* - selections: legacy (kept for compatibility)
|
|
1588
|
+
*/
|
|
1589
|
+
initial?: {
|
|
1590
|
+
values?: Dict;
|
|
1591
|
+
selections?: Record<string, string[]>;
|
|
1592
|
+
};
|
|
1593
|
+
/**
|
|
1594
|
+
* Called on every palette update (values bag).
|
|
1595
|
+
* Use to persist anywhere (state/localStorage/etc).
|
|
1596
|
+
*/
|
|
1597
|
+
onUpdate?: (vals: Dict) => void;
|
|
1507
1598
|
};
|
|
1599
|
+
declare function FormProvider({ children, schema, initial, onUpdate, }: FormProviderProps): react_jsx_runtime.JSX.Element;
|
|
1508
1600
|
|
|
1509
1601
|
/** Matches your InputWrapper’s expectations */
|
|
1510
1602
|
type InputKind = string;
|
|
1511
|
-
type InputVariant =
|
|
1512
|
-
type
|
|
1513
|
-
|
|
1603
|
+
type InputVariant = "default" | (string & {});
|
|
1604
|
+
type AdapterCtx = {
|
|
1605
|
+
field: Field;
|
|
1606
|
+
props: ServiceProps;
|
|
1607
|
+
};
|
|
1608
|
+
type Adapter = {
|
|
1514
1609
|
valueProp?: string;
|
|
1515
|
-
/** Prop name of the change handler on the host component (default: "onChange") */
|
|
1516
1610
|
changeProp?: string;
|
|
1517
|
-
/**
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1611
|
+
/** normalize what the host emitted into what we store in form-palette */
|
|
1612
|
+
getValue?: (next: unknown, current: unknown, ctx: AdapterCtx) => unknown;
|
|
1613
|
+
/** REQUIRED if field.options exists */
|
|
1614
|
+
getSelectedOptions?: (next: unknown, current: unknown, ctx: AdapterCtx) => string[];
|
|
1615
|
+
/** For option-less action buttons (button: true with no options) */
|
|
1616
|
+
isActive?: (stored: unknown, ctx: AdapterCtx) => boolean;
|
|
1617
|
+
getInputPropsFromField?: (props: AdapterCtx) => any;
|
|
1618
|
+
toValue?: (value: any) => any;
|
|
1522
1619
|
};
|
|
1523
1620
|
type InputDescriptor = {
|
|
1524
1621
|
Component: React.ComponentType<Record<string, unknown>>;
|
|
1525
|
-
adapter?:
|
|
1622
|
+
adapter?: Adapter;
|
|
1526
1623
|
defaultProps?: Record<string, unknown>;
|
|
1624
|
+
ui?: Record<string, Ui>;
|
|
1527
1625
|
};
|
|
1528
1626
|
type VariantMap = Map<InputVariant, InputDescriptor>;
|
|
1529
1627
|
type RegistryStore = Map<InputKind, VariantMap>;
|
|
@@ -1563,10 +1661,172 @@ declare function useInputs(): InputsCtxValue;
|
|
|
1563
1661
|
type InputWrapperProps = {
|
|
1564
1662
|
field: Field;
|
|
1565
1663
|
disabled?: boolean;
|
|
1566
|
-
/** Extra props to forward to the host component (low priority, overridden by adapter wiring). */
|
|
1567
1664
|
extraProps?: Record<string, unknown>;
|
|
1665
|
+
templateStrings?: boolean;
|
|
1666
|
+
ctxOverrides?: Record<string, unknown>;
|
|
1667
|
+
};
|
|
1668
|
+
declare function Wrapper({ field, disabled, extraProps, templateStrings, ctxOverrides, }: InputWrapperProps): react_jsx_runtime.JSX.Element | null;
|
|
1669
|
+
|
|
1670
|
+
type OrderFlowInit = {
|
|
1671
|
+
mode?: "prod" | "dev";
|
|
1672
|
+
/** required service map used for snapshot building / rules */
|
|
1673
|
+
services: DgpServiceMap;
|
|
1674
|
+
/** fallback policy overrides */
|
|
1675
|
+
fallback?: FallbackSettings;
|
|
1676
|
+
/** hydrate initial state from snapshot */
|
|
1677
|
+
hydrateFrom?: OrderSnapshot;
|
|
1678
|
+
/** initial tag (ignored if hydrateFrom exists and provides tag) */
|
|
1679
|
+
initialTagId?: string;
|
|
1680
|
+
/** default quantity used by snapshot builder (default 1) */
|
|
1681
|
+
hostDefaultQuantity?: number;
|
|
1682
|
+
/** selection resolver (optional) */
|
|
1683
|
+
resolveService?: (id: number | string) => DgpServiceCapability | undefined;
|
|
1684
|
+
/**
|
|
1685
|
+
* Host props provided to further enhance the nodes data
|
|
1686
|
+
*/
|
|
1687
|
+
ctx?: Record<string, unknown>;
|
|
1688
|
+
};
|
|
1689
|
+
type ProviderFlow = {
|
|
1690
|
+
builder: Builder;
|
|
1691
|
+
selection?: Selection;
|
|
1568
1692
|
};
|
|
1569
|
-
type
|
|
1570
|
-
|
|
1693
|
+
type OrderFlowProviderProps = {
|
|
1694
|
+
/**
|
|
1695
|
+
* Optional at mount time.
|
|
1696
|
+
* If absent, call initialize(...) later (via ref OR hook API).
|
|
1697
|
+
*/
|
|
1698
|
+
serviceProps?: ServiceProps;
|
|
1699
|
+
builder?: Builder;
|
|
1700
|
+
flow?: ProviderFlow;
|
|
1701
|
+
builderOptions?: BuilderOptions;
|
|
1702
|
+
/** optional selection override (if not passed in flow) */
|
|
1703
|
+
selection?: Selection;
|
|
1704
|
+
/** Host input registry (maps kind/variant → components) */
|
|
1705
|
+
registry?: Registry;
|
|
1706
|
+
/** Optional now (deferred init supported). */
|
|
1707
|
+
init?: OrderFlowInit;
|
|
1708
|
+
children?: ReactNode;
|
|
1709
|
+
};
|
|
1710
|
+
type OrderFlowInitializeParams = {
|
|
1711
|
+
serviceProps?: ServiceProps;
|
|
1712
|
+
builder?: Builder;
|
|
1713
|
+
flow?: ProviderFlow;
|
|
1714
|
+
builderOptions?: BuilderOptions;
|
|
1715
|
+
selection?: Selection;
|
|
1716
|
+
init: OrderFlowInit;
|
|
1717
|
+
};
|
|
1718
|
+
type OrderFlowHandle = {
|
|
1719
|
+
/** whether provider has enough info to run */
|
|
1720
|
+
ready: () => boolean;
|
|
1721
|
+
/** (re)initialize the provider */
|
|
1722
|
+
initialize: (params: OrderFlowInitializeParams) => void;
|
|
1723
|
+
getActiveTag: () => string | undefined;
|
|
1724
|
+
selectTag: (tagId: string) => void;
|
|
1725
|
+
getVisibleGroup: () => ReturnType<Selection["visibleGroup"]>;
|
|
1726
|
+
getSelectionIds: () => string[];
|
|
1727
|
+
clearSelection: () => void;
|
|
1728
|
+
/** Apply snapshot into selection + form values/selections */
|
|
1729
|
+
setSnapshot: (snap: OrderSnapshot, opts?: {
|
|
1730
|
+
clearFirst?: boolean;
|
|
1731
|
+
}) => void;
|
|
1732
|
+
/** Reset tag + clear fields */
|
|
1733
|
+
reset: (opts?: {
|
|
1734
|
+
keepTag?: boolean;
|
|
1735
|
+
}) => void;
|
|
1736
|
+
refresh: () => void;
|
|
1737
|
+
};
|
|
1738
|
+
type NormalizedInit = Required<Pick<OrderFlowInit, "mode" | "hostDefaultQuantity">> & OrderFlowInit;
|
|
1739
|
+
type EnsureReadyResult = {
|
|
1740
|
+
builder: Builder;
|
|
1741
|
+
selection: Selection;
|
|
1742
|
+
init: NormalizedInit;
|
|
1743
|
+
};
|
|
1744
|
+
type CtxShape = {
|
|
1745
|
+
builder: Builder | null;
|
|
1746
|
+
selection: Selection | null;
|
|
1747
|
+
activeTagId?: string;
|
|
1748
|
+
setActiveTag: (id: string) => void;
|
|
1749
|
+
init: NormalizedInit | null;
|
|
1750
|
+
/** Form API from FormProvider (always available) */
|
|
1751
|
+
formApi: ReturnType<typeof useFormApi>;
|
|
1752
|
+
/** fallback policy (owned here; used by hook) */
|
|
1753
|
+
fallbackPolicy: FallbackSettings;
|
|
1754
|
+
setFallbackPolicy: (next: FallbackSettings) => void;
|
|
1755
|
+
/** imperative helpers exposed to hook */
|
|
1756
|
+
setSnapshot: (snap: OrderSnapshot, opts?: {
|
|
1757
|
+
clearFirst?: boolean;
|
|
1758
|
+
}) => void;
|
|
1759
|
+
reset: (opts?: {
|
|
1760
|
+
keepTag?: boolean;
|
|
1761
|
+
}) => void;
|
|
1762
|
+
/** guards */
|
|
1763
|
+
ready: () => boolean;
|
|
1764
|
+
ensureReady: (op?: string) => EnsureReadyResult;
|
|
1765
|
+
/** init API */
|
|
1766
|
+
initialize: (params: OrderFlowInitializeParams) => void;
|
|
1767
|
+
};
|
|
1768
|
+
declare function useOrderFlowContext(): CtxShape;
|
|
1769
|
+
declare const OrderFlowProvider: React.ForwardRefExoticComponent<OrderFlowProviderProps & React.RefAttributes<OrderFlowHandle>>;
|
|
1770
|
+
|
|
1771
|
+
type PricingPreview = {
|
|
1772
|
+
serviceId?: string | number;
|
|
1773
|
+
unitRate: number;
|
|
1774
|
+
base: number;
|
|
1775
|
+
utilities: number;
|
|
1776
|
+
total: number;
|
|
1777
|
+
utilityBreakdown: Array<{
|
|
1778
|
+
nodeId: string;
|
|
1779
|
+
mode: string;
|
|
1780
|
+
amount: number;
|
|
1781
|
+
}>;
|
|
1782
|
+
};
|
|
1783
|
+
type UseOrderFlowReturn = {
|
|
1784
|
+
ready: boolean;
|
|
1785
|
+
initialize: (params: OrderFlowInitializeParams) => void;
|
|
1786
|
+
activeTagId?: string;
|
|
1787
|
+
/** raw service props */
|
|
1788
|
+
raw: ServiceProps;
|
|
1789
|
+
/** visibility is Selection-only */
|
|
1790
|
+
visibleGroup: VisibleGroup | null;
|
|
1791
|
+
/**
|
|
1792
|
+
* Values are from form-palette (values()) and are already "visible-only"
|
|
1793
|
+
* because your UI mounts only visible fields.
|
|
1794
|
+
*/
|
|
1795
|
+
formValuesByFieldId: Record<string, Scalar | Scalar[]>;
|
|
1796
|
+
/**
|
|
1797
|
+
* Selections are Selection-only now.
|
|
1798
|
+
* We keep this for compatibility with buildOrderSnapshot signature,
|
|
1799
|
+
* but we do NOT read it from form anymore.
|
|
1800
|
+
*/
|
|
1801
|
+
optionSelectionsByFieldId: Record<string, string[]>;
|
|
1802
|
+
quantityPreview: number;
|
|
1803
|
+
services: Array<string | number>;
|
|
1804
|
+
serviceMap: Record<string, Array<string | number>>;
|
|
1805
|
+
pricingPreview: PricingPreview;
|
|
1806
|
+
min: number;
|
|
1807
|
+
max: number;
|
|
1808
|
+
selectTag: (tagId: string) => void;
|
|
1809
|
+
toggleOption: (fieldId: string, optionId?: string) => void;
|
|
1810
|
+
/** programmatic value set (rare; wrapper/field hook should handle most) */
|
|
1811
|
+
setValue: (fieldId: string, value: Scalar | Scalar[]) => void;
|
|
1812
|
+
clearField: (fieldId: string) => void;
|
|
1813
|
+
reset: (opts?: {
|
|
1814
|
+
keepTag?: boolean;
|
|
1815
|
+
}) => void;
|
|
1816
|
+
setSnapshot: (snap: OrderSnapshot, opts?: {
|
|
1817
|
+
clearFirst?: boolean;
|
|
1818
|
+
}) => void;
|
|
1819
|
+
/** VALIDATES via form.submit() */
|
|
1820
|
+
buildSnapshot: () => OrderSnapshot;
|
|
1821
|
+
fallbackPolicy: FallbackSettings;
|
|
1822
|
+
setFallbackPolicy: (next: FallbackSettings) => void;
|
|
1823
|
+
};
|
|
1824
|
+
declare function useOrderFlow(): UseOrderFlowReturn;
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* Register all built-in entries.
|
|
1828
|
+
* - You said "variant is the only thing necessary", so we treat kind as a constant.
|
|
1829
|
+
*/
|
|
1830
|
+
declare function registerEntries(registry: Registry): void;
|
|
1571
1831
|
|
|
1572
|
-
export { type AdminPolicies, type BaseFieldUI, type ButtonValue, CanvasAPI, type CanvasEvents, type CanvasOptions, type CanvasState, 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, EventBus, type EventMap, type FallbackDiagnostics, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type FormApi, FormProvider, type FormSnapshot, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type
|
|
1832
|
+
export { type Adapter, type AdapterCtx, type AdminPolicies, type BaseFieldUI, type ButtonValue, CanvasAPI, type CanvasEvents, type CanvasOptions, type CanvasState, 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, EventBus, type EventMap, type FallbackDiagnostics, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type InputDescriptor, type InputKind, type InputVariant, type InputWrapperProps, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, OrderFlowProvider, type OrderSnapshot, type PricingRole, Provider, type QuantityMark, type QuantityRule$1 as QuantityRule, type RatePolicy, type Registry, type Scalar, 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, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useFormApi, useInputs, useOptionalFormApi, useOrderFlow, useOrderFlowContext };
|