@judo/model-loader 0.1.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.
@@ -0,0 +1,12 @@
1
+ import { Application, ModelLoaderService } from '@judo/model-api';
2
+ /**
3
+ * HTTP-based model loader.
4
+ * Fetches XML from URL and parses it.
5
+ */
6
+ export declare class HttpModelLoader implements ModelLoaderService {
7
+ /**
8
+ * Load model from HTTP URL.
9
+ */
10
+ load(url: string): Promise<Application[]>;
11
+ }
12
+ //# sourceMappingURL=http-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-loader.d.ts","sourceRoot":"","sources":["../../src/loaders/http-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAKvE;;;GAGG;AACH,qBAAa,eAAgB,YAAW,kBAAkB;IACzD;;OAEG;IACG,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAkB/C"}
@@ -0,0 +1,4 @@
1
+ export { HttpModelLoader } from './http-loader';
2
+ export { FileModelLoader } from './file-loader';
3
+ export { EmbeddedModelLoader } from './embedded-loader';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Parsed cross-reference information.
3
+ */
4
+ export interface ParsedReference {
5
+ namespace?: string;
6
+ actorName?: string;
7
+ elementId: string;
8
+ elementType?: string;
9
+ }
10
+ /**
11
+ * Parse a reference string into its component parts.
12
+ *
13
+ * Reference patterns:
14
+ * - Local: "Actor/(esm/_abc123)/ClassType"
15
+ * - Namespaced: "_default_transferobjecttypes::User"
16
+ * - Cross-actor: "OtherActor/(esm/_xyz789)/ClassType"
17
+ */
18
+ export declare function parseReference(ref: string): ParsedReference;
19
+ /**
20
+ * Build a reference string from parts.
21
+ */
22
+ export declare function buildReference(actorName: string, elementId: string, elementType: string): string;
23
+ /**
24
+ * Check if a reference is namespaced.
25
+ */
26
+ export declare function isNamespacedReference(ref: string): boolean;
27
+ /**
28
+ * Check if a reference crosses actors.
29
+ */
30
+ export declare function isCrossActorReference(ref: string, currentActorName: string): boolean;
31
+ //# sourceMappingURL=cross-reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-reference.d.ts","sourceRoot":"","sources":["../../src/registry/cross-reference.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAyB3D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAEhG;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAGpF"}
@@ -0,0 +1,4 @@
1
+ export { ModelRegistry, type RegistrySnapshot } from './model-registry';
2
+ export { parseReference, buildReference, isNamespacedReference, isCrossActorReference, type ParsedReference, } from './cross-reference';
3
+ export { InstanceReferenceResolver, getContainer, getAncestors, findAncestor, isApplication, isPageContainer, isPageDefinition, REFERENCE_MAPPINGS, REFERENCE_PROPERTIES, type ReferenceMapping, } from './instance-resolver';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACN,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,eAAe,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,gBAAgB,GACrB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { Application, ModelElement, PageContainer, PageDefinition } from '@judo/model-api';
2
+ /**
3
+ * Reference property mapping.
4
+ * Maps property names to the type of element they reference.
5
+ */
6
+ export interface ReferenceMapping {
7
+ property: string;
8
+ targetType: "ClassType" | "DataElement" | "PageDefinition" | "PageContainer" | "ActionDefinition" | "AttributeType" | "RelationType" | "OperationType" | "NavigationItem" | "VisualElement" | "Any";
9
+ }
10
+ /**
11
+ * All known reference properties in the model.
12
+ */
13
+ export declare const REFERENCE_MAPPINGS: ReferenceMapping[];
14
+ /**
15
+ * Properties that are known to be string references.
16
+ */
17
+ export declare const REFERENCE_PROPERTIES: Set<string>;
18
+ /**
19
+ * Resolve all string references to actual object instances.
20
+ * Also sets up eContainer navigation for all elements.
21
+ */
22
+ export declare class InstanceReferenceResolver {
23
+ private elementIndex;
24
+ /**
25
+ * Build index and resolve all references for the given applications.
26
+ * Uses a single-pass algorithm with deferred resolution for better performance.
27
+ */
28
+ resolve(applications: Application[]): void;
29
+ /**
30
+ * Single-pass traversal that indexes elements, sets eContainer,
31
+ * and collects string references for later resolution.
32
+ */
33
+ private indexAndCollectRefs;
34
+ /**
35
+ * Get the element index for testing.
36
+ */
37
+ getIndex(): Map<string, unknown>;
38
+ }
39
+ /**
40
+ * Get the eContainer of an element.
41
+ */
42
+ export declare function getContainer<T extends ModelElement = ModelElement>(element: ModelElement): T | undefined;
43
+ /**
44
+ * Get all ancestors of an element up to the root.
45
+ */
46
+ export declare function getAncestors(element: ModelElement): ModelElement[];
47
+ /**
48
+ * Find the nearest ancestor of a specific type.
49
+ */
50
+ export declare function findAncestor<T extends ModelElement>(element: ModelElement, predicate: (e: ModelElement) => e is T): T | undefined;
51
+ /**
52
+ * Check if an element is an Application.
53
+ */
54
+ export declare function isApplication(element: ModelElement): element is Application;
55
+ /**
56
+ * Check if an element is a PageContainer.
57
+ */
58
+ export declare function isPageContainer(element: ModelElement): element is PageContainer;
59
+ /**
60
+ * Check if an element is a PageDefinition.
61
+ */
62
+ export declare function isPageDefinition(element: ModelElement): element is PageDefinition;
63
+ //# sourceMappingURL=instance-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance-resolver.d.ts","sourceRoot":"","sources":["../../src/registry/instance-resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEhG;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EACP,WAAW,GACX,aAAa,GACb,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,cAAc,GACd,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,KAAK,CAAC;CACT;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EAqFhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,aAAqD,CAAC;AAWvF;;;GAGG;AACH,qBAAa,yBAAyB;IACrC,OAAO,CAAC,YAAY,CAA8B;IAElD;;;OAGG;IACH,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,IAAI;IAqB1C;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAkD3B;;OAEG;IACH,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;CAGhC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAExG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,EAAE,CAUlE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,EAClD,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,CAAC,IAAI,CAAC,GACpC,CAAC,GAAG,SAAS,CAWf;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,IAAI,WAAW,CAE3E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,IAAI,aAAa,CAI/E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,IAAI,cAAc,CAEjF"}
@@ -0,0 +1,129 @@
1
+ import { ActionDefinition, Application, AttributeType, ClassType, DataType, ModelRegistryService, NavigationItem, OperationType, PageContainer, PageDefinition, RelationType, VisualElement } from '@judo/model-api';
2
+ /**
3
+ * Registry snapshot for useSyncExternalStore.
4
+ */
5
+ export interface RegistrySnapshot {
6
+ applications: Application[];
7
+ activeApplication: Application | null;
8
+ activeActorName: string | null;
9
+ }
10
+ /**
11
+ * ModelRegistry manages loaded models and provides element resolution.
12
+ * Automatically resolves string references to object instances and
13
+ * sets up eContainer navigation for all elements.
14
+ */
15
+ export declare class ModelRegistry implements ModelRegistryService {
16
+ private applications;
17
+ private activeActorName;
18
+ private elementIndex;
19
+ private subscribers;
20
+ private instanceResolver;
21
+ private cachedSnapshot;
22
+ /**
23
+ * Register applications from a parsed model.
24
+ * Automatically resolves all string references to object instances
25
+ * and sets up eContainer navigation.
26
+ */
27
+ registerModel(apps: Application[]): void;
28
+ /**
29
+ * Get all registered applications (actors).
30
+ */
31
+ getApplications(): Application[];
32
+ /**
33
+ * Get specific application by actor name.
34
+ * Throws if not found.
35
+ */
36
+ getApplication(actorName: string): Application;
37
+ /**
38
+ * Get currently active application.
39
+ * Throws if none active.
40
+ */
41
+ getActiveApplication(): Application;
42
+ /**
43
+ * Set active application by actor name.
44
+ * Emits change event for subscribers.
45
+ */
46
+ setActiveApplication(actorName: string): void;
47
+ /**
48
+ * Resolve any element by xmi:id.
49
+ */
50
+ resolveById<T = unknown>(id: string): T | undefined;
51
+ /**
52
+ * Resolve ClassType by reference string.
53
+ * Handles cross-model references like `_default_transferobjecttypes::User`.
54
+ */
55
+ resolveClassType(ref: string): ClassType | undefined;
56
+ /**
57
+ * Resolve RelationType by reference string.
58
+ */
59
+ resolveRelationType(ref: string): RelationType | undefined;
60
+ /**
61
+ * Resolve AttributeType by reference string.
62
+ */
63
+ resolveAttributeType(ref: string): AttributeType | undefined;
64
+ /**
65
+ * Resolve PageDefinition by reference string.
66
+ */
67
+ resolvePageDefinition(ref: string): PageDefinition | undefined;
68
+ /**
69
+ * Resolve PageContainer by reference string.
70
+ */
71
+ resolvePageContainer(ref: string): PageContainer | undefined;
72
+ /**
73
+ * Resolve VisualElement by xmi:id or sourceId.
74
+ */
75
+ resolveVisualElement(id: string): VisualElement | undefined;
76
+ /**
77
+ * Resolve ActionDefinition by reference string.
78
+ */
79
+ resolveActionDefinition(ref: string): ActionDefinition | undefined;
80
+ /**
81
+ * Resolve DataType by reference string.
82
+ */
83
+ resolveDataType(ref: string): DataType | undefined;
84
+ /**
85
+ * Resolve OperationType by reference string.
86
+ */
87
+ resolveOperationType(ref: string): OperationType | undefined;
88
+ /**
89
+ * Resolve NavigationItem by xmi:id.
90
+ */
91
+ resolveNavigationItem(id: string): NavigationItem | undefined;
92
+ /**
93
+ * Internal reference resolution.
94
+ *
95
+ * All model references use exact xmi:id values, so direct lookup
96
+ * is sufficient. Returns undefined for unresolvable external references.
97
+ */
98
+ private resolveReference;
99
+ /**
100
+ * Type guard for ClassType.
101
+ */
102
+ private isClassType;
103
+ /**
104
+ * Type guard for RelationType.
105
+ */
106
+ private isRelationType;
107
+ /**
108
+ * Type guard for AttributeType.
109
+ */
110
+ private isAttributeType;
111
+ /**
112
+ * Type guard for OperationType.
113
+ */
114
+ private isOperationType;
115
+ /**
116
+ * Subscribe to registry changes (active app switch).
117
+ */
118
+ subscribe(callback: () => void): () => void;
119
+ /**
120
+ * Get current snapshot for useSyncExternalStore.
121
+ * Returns cached snapshot to maintain referential equality.
122
+ */
123
+ getSnapshot(): RegistrySnapshot;
124
+ /**
125
+ * Notify all subscribers of changes.
126
+ */
127
+ private notifySubscribers;
128
+ }
129
+ //# sourceMappingURL=model-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/registry/model-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,SAAS,EACT,QAAQ,EACR,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,MAAM,iBAAiB,CAAC;AAIzB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,iBAAiB,EAAE,WAAW,GAAG,IAAI,CAAC;IACtC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;;GAIG;AACH,qBAAa,aAAc,YAAW,oBAAoB;IACzD,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,eAAe,CAAu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,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAK7D;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAO3C;;;OAGG;IACH,WAAW,IAAI,gBAAgB;IAa/B;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAOzB"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@judo/model-loader",
3
+ "version": "0.1.0",
4
+ "description": "Model loading and registry services for JUDO UI Runtime",
5
+ "license": "EPL-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/BlackBeltTechnology/judo-frontend-runtime.git",
9
+ "directory": "packages/model-loader"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "LICENSE",
14
+ "README.md"
15
+ ],
16
+ "type": "module",
17
+ "sideEffects": false,
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "browser": "./dist/browser.js",
24
+ "import": "./dist/index.js"
25
+ }
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ "@judo/model-api": "0.1.0",
32
+ "@judo/model-parser": "0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^25.2.3",
36
+ "axios": "^1.13.5",
37
+ "typescript": "^5.9.3",
38
+ "vitest": "^4.0.18",
39
+ "@judo/model-api": "0.1.0",
40
+ "@judo/model-parser": "0.1.0"
41
+ },
42
+ "peerDependencies": {
43
+ "axios": "^1.9.0",
44
+ "@judo/model-api": "0.1.0",
45
+ "@judo/model-parser": "0.1.0"
46
+ },
47
+ "scripts": {
48
+ "build": "vite build",
49
+ "clean": "rm -rf dist",
50
+ "type-check": "tsgo --noEmit",
51
+ "test": "vitest run",
52
+ "test:watch": "vitest"
53
+ }
54
+ }