@ultrst-armada/kloks 1.10.4 → 1.11.0
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/.krusbl-release-attestation.json +3 -3
- package/package.json +1 -1
- package/packages/contracts/dist/index.d.ts +45 -2
- package/packages/contracts/dist/index.js +21 -25
- package/packages/services/dist/index.d.ts +4 -4
- package/packages/services/dist/index.js +223 -186
- package/packages/state-graph/dist/index.js +14 -14
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"packageName": "@ultrst-armada/kloks",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"sourceCommit": "
|
|
4
|
+
"version": "1.11.0",
|
|
5
|
+
"sourceCommit": "40311855e347e1e15506fb3050426448b1a25f76",
|
|
6
6
|
"releaseWorkflow": "npm Release",
|
|
7
|
-
"workflowRunId": "
|
|
7
|
+
"workflowRunId": "40323647247"
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -554,7 +554,8 @@ interface ComponentDescriptor {
|
|
|
554
554
|
}
|
|
555
555
|
interface SectionDescriptor {
|
|
556
556
|
name: string;
|
|
557
|
-
|
|
557
|
+
/** Optional for structural authoring sections that are not reusable components. */
|
|
558
|
+
assetRef?: AssetRef;
|
|
558
559
|
components: ComponentDescriptor[];
|
|
559
560
|
description?: string;
|
|
560
561
|
}
|
|
@@ -617,6 +618,48 @@ interface MonacoUpdateDocumentInput {
|
|
|
617
618
|
value: string;
|
|
618
619
|
language?: string;
|
|
619
620
|
}
|
|
621
|
+
interface MonacoCompletionItem {
|
|
622
|
+
label: string;
|
|
623
|
+
insertText?: string;
|
|
624
|
+
detail?: string;
|
|
625
|
+
documentation?: string;
|
|
626
|
+
kind?: string;
|
|
627
|
+
sortText?: string;
|
|
628
|
+
}
|
|
629
|
+
interface MonacoCompletionRequest {
|
|
630
|
+
sessionId: string;
|
|
631
|
+
uri: string;
|
|
632
|
+
language: string;
|
|
633
|
+
value: string;
|
|
634
|
+
position: {
|
|
635
|
+
lineNumber: number;
|
|
636
|
+
column: number;
|
|
637
|
+
offset: number;
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
interface MonacoWorkspaceContext {
|
|
641
|
+
workspaceId: string;
|
|
642
|
+
rootUri: string;
|
|
643
|
+
files: Array<{
|
|
644
|
+
uri: string;
|
|
645
|
+
language?: string;
|
|
646
|
+
}>;
|
|
647
|
+
dependencies?: Record<string, string>;
|
|
648
|
+
metadata?: Record<string, string>;
|
|
649
|
+
}
|
|
650
|
+
interface MonacoImportAnalysis {
|
|
651
|
+
specifier: string;
|
|
652
|
+
importedSymbols: string[];
|
|
653
|
+
lineNumber: number;
|
|
654
|
+
resolvedUri?: string;
|
|
655
|
+
resolved: boolean;
|
|
656
|
+
}
|
|
657
|
+
interface MonacoValidationResult {
|
|
658
|
+
valid: boolean;
|
|
659
|
+
diagnostics: MonacoDiagnostic[];
|
|
660
|
+
checkedAt: number;
|
|
661
|
+
}
|
|
662
|
+
type MonacoCompletionProvider = (request: MonacoCompletionRequest) => Promise<MonacoCompletionItem[]>;
|
|
620
663
|
|
|
621
664
|
type UIAuthoringContext = 'service' | 'general-component' | 'application';
|
|
622
665
|
type UIAuthoringNodeKind = 'page' | 'section' | 'component';
|
|
@@ -720,4 +763,4 @@ declare const KLOKS_CANONICAL_CONTRACT: {
|
|
|
720
763
|
validateCompatibility: (consumerSymbols?: string[]) => CompatibilityCheckResult;
|
|
721
764
|
};
|
|
722
765
|
|
|
723
|
-
export { type AssetRef, type AudioBusConfig, AudioBusConfigSchema, type AudioHardwareState, AudioHardwareStateSchema, type BackendOperation, BackendOperationSchema, type CompatibilityCheckResult, type ComponentDescriptor, type ContractDiffResult, type ContractSnapshot, ContractSnapshotSchema, type ExportSymbolEntry, type GraphEntityMetadata, GraphEntityMetadataSchema, KLOKS_CANONICAL_CONTRACT, KLOKS_PUBLIC_SURFACE, type MidiCommandType, MidiCommandTypeSchema, type MidiEventPayload, MidiEventPayloadSchema, type MonacoCreateSessionInput, type MonacoDiagnostic, type MonacoDiagnosticSeverity, type MonacoDocument, type MonacoEditorOptions, type MonacoIdeSession, type MonacoUpdateDocumentInput, type NodeDimensions2D, NodeDimensions2DSchema, type NodeHeaderStyle, NodeHeaderStyleSchema, type NodeScreenRect2D, NodeScreenRect2DSchema, type OperationBinding, type PageDescriptor, type PublicContractDefinition, PublicContractDefinitionSchema, QWNSR_REQUIRED_SURFACE, type SectionDescriptor, type ServiceUISchema, type SocketDirection, SocketDirectionSchema, type SocketGeometryConfig, SocketGeometryConfigSchema, type SocketPosition2D, SocketPosition2DSchema, type SocketStyleConfig, SocketStyleConfigSchema, type UIAuthoringBinding, type UIAuthoringContext, type UIAuthoringCreateInput, type UIAuthoringNode, type UIAuthoringNodeKind, type UIAuthoringOperation, type UIAuthoringSession, type UIAuthoringValidation, type UIComponentArtifact, type UIComponentPromotion, type UIComponentPurpose, type UIRequirementMode, UI_AUTHORING_SCHEMA_VERSION, type WireAnimationConfig, WireAnimationConfigSchema, type WireCurveStyle, WireCurveStyleSchema, type WireEndpoint2D, WireEndpoint2DSchema, type WireVisualConfig, WireVisualConfigSchema, buildServiceUISchema, buildUIComponentArtifact, createKloksSnapshot, diffContractSnapshots, getUIComponentPromotion, getUIComponentPurpose, suggestUIComponent, validateConsumerSurfaceCompatibility };
|
|
766
|
+
export { type AssetRef, type AudioBusConfig, AudioBusConfigSchema, type AudioHardwareState, AudioHardwareStateSchema, type BackendOperation, BackendOperationSchema, type CompatibilityCheckResult, type ComponentDescriptor, type ContractDiffResult, type ContractSnapshot, ContractSnapshotSchema, type ExportSymbolEntry, type GraphEntityMetadata, GraphEntityMetadataSchema, KLOKS_CANONICAL_CONTRACT, KLOKS_PUBLIC_SURFACE, type MidiCommandType, MidiCommandTypeSchema, type MidiEventPayload, MidiEventPayloadSchema, type MonacoCompletionItem, type MonacoCompletionProvider, type MonacoCompletionRequest, type MonacoCreateSessionInput, type MonacoDiagnostic, type MonacoDiagnosticSeverity, type MonacoDocument, type MonacoEditorOptions, type MonacoIdeSession, type MonacoImportAnalysis, type MonacoUpdateDocumentInput, type MonacoValidationResult, type MonacoWorkspaceContext, type NodeDimensions2D, NodeDimensions2DSchema, type NodeHeaderStyle, NodeHeaderStyleSchema, type NodeScreenRect2D, NodeScreenRect2DSchema, type OperationBinding, type PageDescriptor, type PublicContractDefinition, PublicContractDefinitionSchema, QWNSR_REQUIRED_SURFACE, type SectionDescriptor, type ServiceUISchema, type SocketDirection, SocketDirectionSchema, type SocketGeometryConfig, SocketGeometryConfigSchema, type SocketPosition2D, SocketPosition2DSchema, type SocketStyleConfig, SocketStyleConfigSchema, type UIAuthoringBinding, type UIAuthoringContext, type UIAuthoringCreateInput, type UIAuthoringNode, type UIAuthoringNodeKind, type UIAuthoringOperation, type UIAuthoringSession, type UIAuthoringValidation, type UIComponentArtifact, type UIComponentPromotion, type UIComponentPurpose, type UIRequirementMode, UI_AUTHORING_SCHEMA_VERSION, type WireAnimationConfig, WireAnimationConfigSchema, type WireCurveStyle, WireCurveStyleSchema, type WireEndpoint2D, WireEndpoint2DSchema, type WireVisualConfig, WireVisualConfigSchema, buildServiceUISchema, buildUIComponentArtifact, createKloksSnapshot, diffContractSnapshots, getUIComponentPromotion, getUIComponentPurpose, suggestUIComponent, validateConsumerSurfaceCompatibility };
|
|
@@ -397,7 +397,24 @@ function buildServiceUISchema(session) {
|
|
|
397
397
|
const pages = session.nodes.filter((node) => node.kind === "page");
|
|
398
398
|
const sections = session.nodes.filter((node) => node.kind === "section");
|
|
399
399
|
const components = session.nodes.filter((node) => node.kind === "component");
|
|
400
|
-
const assetRefs =
|
|
400
|
+
const assetRefs = [
|
|
401
|
+
...sections.map((node) => node.assetRef),
|
|
402
|
+
...components.map((node) => node.assetRef)
|
|
403
|
+
].filter(Boolean);
|
|
404
|
+
const componentDescriptor = (component) => {
|
|
405
|
+
if (!component.assetRef) throw new Error(`Component '${component.id}' requires a FLOKS asset reference before ServiceUISchema generation.`);
|
|
406
|
+
return {
|
|
407
|
+
name: component.name,
|
|
408
|
+
assetRef: component.assetRef,
|
|
409
|
+
description: component.props.description
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
const sectionDescriptor = (section) => ({
|
|
413
|
+
name: section.name,
|
|
414
|
+
...section.assetRef ? { assetRef: section.assetRef } : {},
|
|
415
|
+
components: components.filter((component) => component.parentId === section.id).map(componentDescriptor),
|
|
416
|
+
description: section.props.description
|
|
417
|
+
});
|
|
401
418
|
return {
|
|
402
419
|
schemaId: `kloks.authored-ui.${session.sessionId}`,
|
|
403
420
|
schemaVersion: UI_AUTHORING_SCHEMA_VERSION,
|
|
@@ -405,32 +422,11 @@ function buildServiceUISchema(session) {
|
|
|
405
422
|
requirementMode: "optional",
|
|
406
423
|
pages: pages.map((page) => ({
|
|
407
424
|
name: page.name,
|
|
408
|
-
sections: sections.filter((section) => section.parentId === page.id).map(
|
|
409
|
-
name: section.name,
|
|
410
|
-
assetRef: section.assetRef,
|
|
411
|
-
components: components.filter((component) => component.parentId === section.id).map((component) => ({
|
|
412
|
-
name: component.name,
|
|
413
|
-
assetRef: component.assetRef,
|
|
414
|
-
description: component.props.description
|
|
415
|
-
})),
|
|
416
|
-
description: section.props.description
|
|
417
|
-
})),
|
|
425
|
+
sections: sections.filter((section) => section.parentId === page.id).map(sectionDescriptor),
|
|
418
426
|
description: page.props.description
|
|
419
427
|
})),
|
|
420
|
-
sections: sections.map(
|
|
421
|
-
|
|
422
|
-
assetRef: section.assetRef,
|
|
423
|
-
components: components.filter((component) => component.parentId === section.id).map((component) => ({
|
|
424
|
-
name: component.name,
|
|
425
|
-
assetRef: component.assetRef
|
|
426
|
-
})),
|
|
427
|
-
description: section.props.description
|
|
428
|
-
})),
|
|
429
|
-
components: components.map((component) => ({
|
|
430
|
-
name: component.name,
|
|
431
|
-
assetRef: component.assetRef,
|
|
432
|
-
description: component.props.description
|
|
433
|
-
})),
|
|
428
|
+
sections: sections.map(sectionDescriptor),
|
|
429
|
+
components: components.map(componentDescriptor),
|
|
434
430
|
assetRefs,
|
|
435
431
|
operationBindings: session.bindings.map((binding) => ({
|
|
436
432
|
operationId: binding.target.apiId,
|
|
@@ -279,7 +279,7 @@ declare const SystemDbServiceUISchema: ServiceUISchema;
|
|
|
279
279
|
interface MonacoState extends Record<string, unknown> {
|
|
280
280
|
sessions: Record<string, MonacoIdeSession>;
|
|
281
281
|
}
|
|
282
|
-
declare const MonacoIdeServiceDefinition: ServiceDefinition<MonacoState
|
|
282
|
+
declare const MonacoIdeServiceDefinition: ServiceDefinition<MonacoState, Record<string, unknown>>;
|
|
283
283
|
declare function createMonacoIdeService(): IService<MonacoState>;
|
|
284
284
|
declare const MonacoIdeServiceFacade: {
|
|
285
285
|
id: string;
|
|
@@ -288,7 +288,7 @@ declare const MonacoIdeServiceFacade: {
|
|
|
288
288
|
runtime: "client";
|
|
289
289
|
deployment: "local";
|
|
290
290
|
definition: ServiceDefinition<MonacoState, Record<string, unknown>>;
|
|
291
|
-
service:
|
|
291
|
+
service: _ultrst_armada_krnl.ServiceInstance<MonacoState, Record<string, unknown>>;
|
|
292
292
|
createInstance: typeof createMonacoIdeService;
|
|
293
293
|
execute: <TIn = unknown, TOut = unknown>(operation: string, input?: TIn) => Promise<TOut>;
|
|
294
294
|
};
|
|
@@ -296,7 +296,7 @@ declare const MonacoIdeServiceFacade: {
|
|
|
296
296
|
interface UIAuthoringState extends Record<string, unknown> {
|
|
297
297
|
sessions: Record<string, UIAuthoringSession>;
|
|
298
298
|
}
|
|
299
|
-
declare const UIAuthoringServiceDefinition: ServiceDefinition<UIAuthoringState
|
|
299
|
+
declare const UIAuthoringServiceDefinition: ServiceDefinition<UIAuthoringState, Record<string, unknown>>;
|
|
300
300
|
declare function createUIAuthoringService(): IService<UIAuthoringState>;
|
|
301
301
|
declare const UIAuthoringServiceFacade: {
|
|
302
302
|
id: string;
|
|
@@ -305,7 +305,7 @@ declare const UIAuthoringServiceFacade: {
|
|
|
305
305
|
runtime: "client";
|
|
306
306
|
deployment: "local";
|
|
307
307
|
definition: ServiceDefinition<UIAuthoringState, Record<string, unknown>>;
|
|
308
|
-
service:
|
|
308
|
+
service: _ultrst_armada_krnl.ServiceInstance<UIAuthoringState, Record<string, unknown>>;
|
|
309
309
|
createInstance: typeof createUIAuthoringService;
|
|
310
310
|
execute: <TIn = unknown, TOut = unknown>(operation: string, input?: TIn) => Promise<TOut>;
|
|
311
311
|
};
|
|
@@ -1653,94 +1653,99 @@ var storageService = new StorageService();
|
|
|
1653
1653
|
|
|
1654
1654
|
// src/client-services/monacoIdeService.ts
|
|
1655
1655
|
var activeMonacoService;
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1656
|
+
function buildMonacoIdeServiceDefinition(getService) {
|
|
1657
|
+
return createServiceDefinition({
|
|
1658
|
+
id: "kloks.service.monacoIde",
|
|
1659
|
+
name: "MonacoIdeService",
|
|
1660
|
+
version: "1.0.0",
|
|
1661
|
+
state: { initial: { sessions: {} } },
|
|
1662
|
+
operations: {
|
|
1663
|
+
createSession: {
|
|
1664
|
+
id: "MonacoIdeService.createSession",
|
|
1665
|
+
name: "createSession",
|
|
1666
|
+
handler: async (input, ctx) => {
|
|
1667
|
+
const sessionId = input.sessionId || `monaco-${Date.now().toString(36)}`;
|
|
1668
|
+
const now = Date.now();
|
|
1669
|
+
const session = {
|
|
1670
|
+
sessionId,
|
|
1671
|
+
document: { uri: input.uri, language: input.language, value: input.value, version: 1, diagnostics: [] },
|
|
1672
|
+
options: input.options || {},
|
|
1673
|
+
createdAt: now,
|
|
1674
|
+
updatedAt: now
|
|
1675
|
+
};
|
|
1676
|
+
getService().setState({ sessions: { ...getService().getState().sessions, [sessionId]: session } });
|
|
1677
|
+
return session;
|
|
1678
|
+
}
|
|
1679
|
+
},
|
|
1680
|
+
updateDocument: {
|
|
1681
|
+
id: "MonacoIdeService.updateDocument",
|
|
1682
|
+
name: "updateDocument",
|
|
1683
|
+
handler: async (input, ctx) => {
|
|
1684
|
+
const current = getService().getState().sessions[input.sessionId];
|
|
1685
|
+
if (!current) throw new Error(`Unknown Monaco session: ${input.sessionId}`);
|
|
1686
|
+
const document = {
|
|
1687
|
+
...current.document,
|
|
1688
|
+
value: input.value,
|
|
1689
|
+
language: input.language || current.document.language,
|
|
1690
|
+
version: current.document.version + 1
|
|
1691
|
+
};
|
|
1692
|
+
const session = { ...current, document, updatedAt: Date.now() };
|
|
1693
|
+
getService().setState({ sessions: { ...getService().getState().sessions, [session.sessionId]: session } });
|
|
1694
|
+
return session;
|
|
1695
|
+
}
|
|
1696
|
+
},
|
|
1697
|
+
setDiagnostics: {
|
|
1698
|
+
id: "MonacoIdeService.setDiagnostics",
|
|
1699
|
+
name: "setDiagnostics",
|
|
1700
|
+
handler: async (input, ctx) => {
|
|
1701
|
+
const current = getService().getState().sessions[input.sessionId];
|
|
1702
|
+
if (!current) throw new Error(`Unknown Monaco session: ${input.sessionId}`);
|
|
1703
|
+
const session = {
|
|
1704
|
+
...current,
|
|
1705
|
+
document: { ...current.document, diagnostics: input.diagnostics },
|
|
1706
|
+
updatedAt: Date.now()
|
|
1707
|
+
};
|
|
1708
|
+
getService().setState({ sessions: { ...getService().getState().sessions, [session.sessionId]: session } });
|
|
1709
|
+
return session;
|
|
1710
|
+
}
|
|
1711
|
+
},
|
|
1712
|
+
setOptions: {
|
|
1713
|
+
id: "MonacoIdeService.setOptions",
|
|
1714
|
+
name: "setOptions",
|
|
1715
|
+
handler: async (input, ctx) => {
|
|
1716
|
+
const current = getService().getState().sessions[input.sessionId];
|
|
1717
|
+
if (!current) throw new Error(`Unknown Monaco session: ${input.sessionId}`);
|
|
1718
|
+
const session = { ...current, options: { ...current.options, ...input.options }, updatedAt: Date.now() };
|
|
1719
|
+
getService().setState({ sessions: { ...getService().getState().sessions, [session.sessionId]: session } });
|
|
1720
|
+
return session;
|
|
1721
|
+
}
|
|
1722
|
+
},
|
|
1723
|
+
getSession: {
|
|
1724
|
+
id: "MonacoIdeService.getSession",
|
|
1725
|
+
name: "getSession",
|
|
1726
|
+
handler: async (input, ctx) => getService().getState().sessions[input.sessionId] || null
|
|
1727
|
+
},
|
|
1728
|
+
disposeSession: {
|
|
1729
|
+
id: "MonacoIdeService.disposeSession",
|
|
1730
|
+
name: "disposeSession",
|
|
1731
|
+
handler: async (input, ctx) => {
|
|
1732
|
+
const sessions = { ...getService().getState().sessions };
|
|
1733
|
+
delete sessions[input.sessionId];
|
|
1734
|
+
getService().setState({ sessions });
|
|
1735
|
+
return { disposed: true, sessionId: input.sessionId };
|
|
1736
|
+
}
|
|
1735
1737
|
}
|
|
1736
1738
|
}
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
var MonacoIdeServiceDefinition = buildMonacoIdeServiceDefinition(() => activeMonacoService);
|
|
1739
1742
|
function createMonacoIdeService() {
|
|
1740
|
-
|
|
1741
|
-
|
|
1743
|
+
let instance;
|
|
1744
|
+
instance = createService(buildMonacoIdeServiceDefinition(() => instance));
|
|
1745
|
+
return instance;
|
|
1742
1746
|
}
|
|
1743
|
-
var defaultMonacoIdeService =
|
|
1747
|
+
var defaultMonacoIdeService = createService(MonacoIdeServiceDefinition);
|
|
1748
|
+
activeMonacoService = defaultMonacoIdeService;
|
|
1744
1749
|
var MonacoIdeServiceFacade = {
|
|
1745
1750
|
id: MonacoIdeServiceDefinition.id,
|
|
1746
1751
|
name: MonacoIdeServiceDefinition.name,
|
|
@@ -1759,106 +1764,136 @@ var MonacoIdeServiceFacade = {
|
|
|
1759
1764
|
// src/client-services/uiAuthoringService.ts
|
|
1760
1765
|
import { buildServiceUISchema, buildUIComponentArtifact, suggestUIComponent } from "@ultrst-armada/kloks/contracts";
|
|
1761
1766
|
var activeUIAuthoringService;
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1767
|
+
function buildUIAuthoringServiceDefinition(getService) {
|
|
1768
|
+
return createServiceDefinition({
|
|
1769
|
+
id: "kloks.service.uiAuthoring",
|
|
1770
|
+
name: "UIAuthoringService",
|
|
1771
|
+
version: "1.0.0",
|
|
1772
|
+
state: { initial: { sessions: {} } },
|
|
1773
|
+
operations: {
|
|
1774
|
+
createSession: {
|
|
1775
|
+
id: "UIAuthoringService.createSession",
|
|
1776
|
+
name: "createSession",
|
|
1777
|
+
handler: async (input, ctx) => {
|
|
1778
|
+
const sessionId = input.sessionId || `ui-authoring-${Date.now().toString(36)}`;
|
|
1779
|
+
const session = {
|
|
1780
|
+
sessionId,
|
|
1781
|
+
context: input.context,
|
|
1782
|
+
nodes: [],
|
|
1783
|
+
bindings: [],
|
|
1784
|
+
operations: input.operations || [],
|
|
1785
|
+
metadata: input.metadata || {}
|
|
1786
|
+
};
|
|
1787
|
+
getService().setState({ sessions: { ...getService().getState().sessions, [sessionId]: session } });
|
|
1788
|
+
return session;
|
|
1789
|
+
}
|
|
1790
|
+
},
|
|
1791
|
+
replaceSession: {
|
|
1792
|
+
id: "UIAuthoringService.replaceSession",
|
|
1793
|
+
name: "replaceSession",
|
|
1794
|
+
handler: async (input, ctx) => {
|
|
1795
|
+
if (input.sessionId !== input.session.sessionId) throw new Error("Session id mismatch.");
|
|
1796
|
+
return updateSession(getService(), input.sessionId, () => input.session);
|
|
1797
|
+
}
|
|
1798
|
+
},
|
|
1799
|
+
addNode: {
|
|
1800
|
+
id: "UIAuthoringService.addNode",
|
|
1801
|
+
name: "addNode",
|
|
1802
|
+
handler: async (input, ctx) => updateSession(getService(), input.sessionId, (session) => ({
|
|
1803
|
+
...session,
|
|
1804
|
+
nodes: [...session.nodes.filter((node) => node.id !== input.node.id), input.node]
|
|
1805
|
+
}))
|
|
1806
|
+
},
|
|
1807
|
+
updateNode: {
|
|
1808
|
+
id: "UIAuthoringService.updateNode",
|
|
1809
|
+
name: "updateNode",
|
|
1810
|
+
handler: async (input, ctx) => updateSession(getService(), input.sessionId, (session) => ({
|
|
1811
|
+
...session,
|
|
1812
|
+
nodes: session.nodes.map((node) => node.id === input.nodeId ? { ...node, ...input.patch } : node)
|
|
1813
|
+
}))
|
|
1814
|
+
},
|
|
1815
|
+
removeNode: {
|
|
1816
|
+
id: "UIAuthoringService.removeNode",
|
|
1817
|
+
name: "removeNode",
|
|
1818
|
+
handler: async (input, ctx) => updateSession(getService(), input.sessionId, (session) => {
|
|
1819
|
+
const removedIds = /* @__PURE__ */ new Set([input.nodeId]);
|
|
1820
|
+
let expanded = true;
|
|
1821
|
+
while (expanded) {
|
|
1822
|
+
expanded = false;
|
|
1823
|
+
for (const node of session.nodes) {
|
|
1824
|
+
if (node.parentId && removedIds.has(node.parentId) && !removedIds.has(node.id)) {
|
|
1825
|
+
removedIds.add(node.id);
|
|
1826
|
+
expanded = true;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
return {
|
|
1831
|
+
...session,
|
|
1832
|
+
nodes: session.nodes.filter((node) => !removedIds.has(node.id)).map((node) => ({
|
|
1833
|
+
...node,
|
|
1834
|
+
slots: node.slots ? Object.fromEntries(Object.entries(node.slots).map(([slot, children]) => [
|
|
1835
|
+
slot,
|
|
1836
|
+
children.filter((childId) => !removedIds.has(childId))
|
|
1837
|
+
])) : void 0
|
|
1838
|
+
})),
|
|
1839
|
+
bindings: session.bindings.filter((binding) => !removedIds.has(binding.componentId))
|
|
1840
|
+
};
|
|
1841
|
+
})
|
|
1842
|
+
},
|
|
1843
|
+
setBinding: {
|
|
1844
|
+
id: "UIAuthoringService.setBinding",
|
|
1845
|
+
name: "setBinding",
|
|
1846
|
+
handler: async (input, ctx) => updateSession(getService(), input.sessionId, (session) => ({
|
|
1847
|
+
...session,
|
|
1848
|
+
bindings: [...session.bindings.filter((binding) => binding.componentId !== input.binding.componentId || binding.property !== input.binding.property), input.binding]
|
|
1849
|
+
}))
|
|
1850
|
+
},
|
|
1851
|
+
setOperations: {
|
|
1852
|
+
id: "UIAuthoringService.setOperations",
|
|
1853
|
+
name: "setOperations",
|
|
1854
|
+
handler: async (input, ctx) => updateSession(getService(), input.sessionId, (session) => ({ ...session, operations: input.operations }))
|
|
1855
|
+
},
|
|
1856
|
+
validate: {
|
|
1857
|
+
id: "UIAuthoringService.validate",
|
|
1858
|
+
name: "validate",
|
|
1859
|
+
handler: async (input, ctx) => validateSession(getSession(getService(), input.sessionId))
|
|
1860
|
+
},
|
|
1861
|
+
serialize: {
|
|
1862
|
+
id: "UIAuthoringService.serialize",
|
|
1863
|
+
name: "serialize",
|
|
1864
|
+
handler: async (input, ctx) => JSON.stringify(getSession(getService(), input.sessionId), null, 2)
|
|
1865
|
+
},
|
|
1866
|
+
generateArtifact: {
|
|
1867
|
+
id: "UIAuthoringService.generateArtifact",
|
|
1868
|
+
name: "generateArtifact",
|
|
1869
|
+
handler: async (input, ctx) => buildUIComponentArtifact(getSession(getService(), input.sessionId))
|
|
1870
|
+
},
|
|
1871
|
+
generateServiceUI: {
|
|
1872
|
+
id: "UIAuthoringService.generateServiceUI",
|
|
1873
|
+
name: "generateServiceUI",
|
|
1874
|
+
handler: async (input, ctx) => {
|
|
1875
|
+
const session = getSession(getService(), input.sessionId);
|
|
1876
|
+
const validation = validateSession(session);
|
|
1877
|
+
if (!validation.valid) {
|
|
1878
|
+
throw new Error(`Cannot generate ServiceUISchema: ${validation.errors.join("; ")}`);
|
|
1879
|
+
}
|
|
1880
|
+
return buildServiceUISchema(session);
|
|
1881
|
+
}
|
|
1882
|
+
},
|
|
1883
|
+
suggestComponent: {
|
|
1884
|
+
id: "UIAuthoringService.suggestComponent",
|
|
1885
|
+
name: "suggestComponent",
|
|
1886
|
+
handler: async (input) => suggestUIComponent(input.fieldType)
|
|
1887
|
+
},
|
|
1888
|
+
getSession: {
|
|
1889
|
+
id: "UIAuthoringService.getSession",
|
|
1890
|
+
name: "getSession",
|
|
1891
|
+
handler: async (input, ctx) => getService().getState().sessions[input.sessionId] || null
|
|
1791
1892
|
}
|
|
1792
|
-
},
|
|
1793
|
-
addNode: {
|
|
1794
|
-
id: "UIAuthoringService.addNode",
|
|
1795
|
-
name: "addNode",
|
|
1796
|
-
handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({
|
|
1797
|
-
...session,
|
|
1798
|
-
nodes: [...session.nodes.filter((node) => node.id !== input.node.id), input.node]
|
|
1799
|
-
}))
|
|
1800
|
-
},
|
|
1801
|
-
updateNode: {
|
|
1802
|
-
id: "UIAuthoringService.updateNode",
|
|
1803
|
-
name: "updateNode",
|
|
1804
|
-
handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({
|
|
1805
|
-
...session,
|
|
1806
|
-
nodes: session.nodes.map((node) => node.id === input.nodeId ? { ...node, ...input.patch } : node)
|
|
1807
|
-
}))
|
|
1808
|
-
},
|
|
1809
|
-
removeNode: {
|
|
1810
|
-
id: "UIAuthoringService.removeNode",
|
|
1811
|
-
name: "removeNode",
|
|
1812
|
-
handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({
|
|
1813
|
-
...session,
|
|
1814
|
-
nodes: session.nodes.filter((node) => node.id !== input.nodeId && node.parentId !== input.nodeId)
|
|
1815
|
-
}))
|
|
1816
|
-
},
|
|
1817
|
-
setBinding: {
|
|
1818
|
-
id: "UIAuthoringService.setBinding",
|
|
1819
|
-
name: "setBinding",
|
|
1820
|
-
handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({
|
|
1821
|
-
...session,
|
|
1822
|
-
bindings: [...session.bindings.filter((binding) => binding.componentId !== input.binding.componentId || binding.property !== input.binding.property), input.binding]
|
|
1823
|
-
}))
|
|
1824
|
-
},
|
|
1825
|
-
setOperations: {
|
|
1826
|
-
id: "UIAuthoringService.setOperations",
|
|
1827
|
-
name: "setOperations",
|
|
1828
|
-
handler: async (input, ctx) => updateSession(activeUIAuthoringService, input.sessionId, (session) => ({ ...session, operations: input.operations }))
|
|
1829
|
-
},
|
|
1830
|
-
validate: {
|
|
1831
|
-
id: "UIAuthoringService.validate",
|
|
1832
|
-
name: "validate",
|
|
1833
|
-
handler: async (input, ctx) => validateSession(getSession(activeUIAuthoringService, input.sessionId))
|
|
1834
|
-
},
|
|
1835
|
-
serialize: {
|
|
1836
|
-
id: "UIAuthoringService.serialize",
|
|
1837
|
-
name: "serialize",
|
|
1838
|
-
handler: async (input, ctx) => JSON.stringify(getSession(activeUIAuthoringService, input.sessionId), null, 2)
|
|
1839
|
-
},
|
|
1840
|
-
generateArtifact: {
|
|
1841
|
-
id: "UIAuthoringService.generateArtifact",
|
|
1842
|
-
name: "generateArtifact",
|
|
1843
|
-
handler: async (input, ctx) => buildUIComponentArtifact(getSession(activeUIAuthoringService, input.sessionId))
|
|
1844
|
-
},
|
|
1845
|
-
generateServiceUI: {
|
|
1846
|
-
id: "UIAuthoringService.generateServiceUI",
|
|
1847
|
-
name: "generateServiceUI",
|
|
1848
|
-
handler: async (input, ctx) => buildServiceUISchema(getSession(activeUIAuthoringService, input.sessionId))
|
|
1849
|
-
},
|
|
1850
|
-
suggestComponent: {
|
|
1851
|
-
id: "UIAuthoringService.suggestComponent",
|
|
1852
|
-
name: "suggestComponent",
|
|
1853
|
-
handler: async (input) => suggestUIComponent(input.fieldType)
|
|
1854
|
-
},
|
|
1855
|
-
getSession: {
|
|
1856
|
-
id: "UIAuthoringService.getSession",
|
|
1857
|
-
name: "getSession",
|
|
1858
|
-
handler: async (input, ctx) => activeUIAuthoringService.getState().sessions[input.sessionId] || null
|
|
1859
1893
|
}
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
var UIAuthoringServiceDefinition = buildUIAuthoringServiceDefinition(() => activeUIAuthoringService);
|
|
1862
1897
|
function getSession(service, sessionId) {
|
|
1863
1898
|
const session = service.getState().sessions[sessionId];
|
|
1864
1899
|
if (!session) throw new Error(`Unknown UI authoring session: ${sessionId}`);
|
|
@@ -1882,7 +1917,7 @@ function validateSession(session) {
|
|
|
1882
1917
|
if (node.kind === "section" && !node.parentId) errors.push(`Section requires a page parent: ${node.id}`);
|
|
1883
1918
|
if (node.kind === "section" && node.parentId && !session.nodes.some((parent) => parent.id === node.parentId && parent.kind === "page")) errors.push(`Section parent must be a page: ${node.id}`);
|
|
1884
1919
|
if (node.kind === "component" && !node.parentId) errors.push(`Component requires a section parent: ${node.id}`);
|
|
1885
|
-
if (node.kind === "component" && node.parentId && !session.nodes.some((parent) => parent.id === node.parentId && parent.kind === "section")) errors.push(`Component parent must be a section: ${node.id}`);
|
|
1920
|
+
if (node.kind === "component" && node.parentId && !session.nodes.some((parent) => parent.id === node.parentId && (parent.kind === "section" || parent.kind === "component"))) errors.push(`Component parent must be a section or component: ${node.id}`);
|
|
1886
1921
|
}
|
|
1887
1922
|
if (session.nodes.some((node) => node.kind === "component" && !node.assetRef)) errors.push("Every component node requires a FLOKS asset reference.");
|
|
1888
1923
|
if (session.context === "service" && !session.metadata.serviceId) errors.push("Service authoring requires metadata.serviceId.");
|
|
@@ -1922,10 +1957,12 @@ function validateSession(session) {
|
|
|
1922
1957
|
return { valid: errors.length === 0, errors, warnings };
|
|
1923
1958
|
}
|
|
1924
1959
|
function createUIAuthoringService() {
|
|
1925
|
-
|
|
1926
|
-
|
|
1960
|
+
let instance;
|
|
1961
|
+
instance = createService(buildUIAuthoringServiceDefinition(() => instance));
|
|
1962
|
+
return instance;
|
|
1927
1963
|
}
|
|
1928
|
-
var defaultUIAuthoringService =
|
|
1964
|
+
var defaultUIAuthoringService = createService(UIAuthoringServiceDefinition);
|
|
1965
|
+
activeUIAuthoringService = defaultUIAuthoringService;
|
|
1929
1966
|
var UIAuthoringServiceFacade = {
|
|
1930
1967
|
id: UIAuthoringServiceDefinition.id,
|
|
1931
1968
|
name: UIAuthoringServiceDefinition.name,
|
|
@@ -16,20 +16,6 @@ import {
|
|
|
16
16
|
useSkipoBind,
|
|
17
17
|
useSkipoState
|
|
18
18
|
} from "./chunk-EW4ACSZB.js";
|
|
19
|
-
import {
|
|
20
|
-
CommandApi,
|
|
21
|
-
GhostStore,
|
|
22
|
-
GraphStore
|
|
23
|
-
} from "./chunk-4UVGXFEM.js";
|
|
24
|
-
import {
|
|
25
|
-
BaseGraph,
|
|
26
|
-
BaseNode,
|
|
27
|
-
BaseViewWindow,
|
|
28
|
-
CustomGraph,
|
|
29
|
-
CustomNode,
|
|
30
|
-
CustomViewWindow,
|
|
31
|
-
DEFAULT_GRAPH_SETTINGS
|
|
32
|
-
} from "./chunk-KG6QYS26.js";
|
|
33
19
|
import {
|
|
34
20
|
AttractionEngine,
|
|
35
21
|
GhostInferenceEngine,
|
|
@@ -45,6 +31,20 @@ import {
|
|
|
45
31
|
WireTypeRegistry,
|
|
46
32
|
initializeDefaultGraphRules
|
|
47
33
|
} from "./chunk-TZOL3RN7.js";
|
|
34
|
+
import {
|
|
35
|
+
CommandApi,
|
|
36
|
+
GhostStore,
|
|
37
|
+
GraphStore
|
|
38
|
+
} from "./chunk-4UVGXFEM.js";
|
|
39
|
+
import {
|
|
40
|
+
BaseGraph,
|
|
41
|
+
BaseNode,
|
|
42
|
+
BaseViewWindow,
|
|
43
|
+
CustomGraph,
|
|
44
|
+
CustomNode,
|
|
45
|
+
CustomViewWindow,
|
|
46
|
+
DEFAULT_GRAPH_SETTINGS
|
|
47
|
+
} from "./chunk-KG6QYS26.js";
|
|
48
48
|
import {
|
|
49
49
|
AutoSolidify,
|
|
50
50
|
SpatialEngine,
|