@judo/model-parser 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.
- package/LICENSE +277 -0
- package/README.md +109 -0
- package/dist/containment-builder.d.ts +17 -0
- package/dist/containment-builder.d.ts.map +1 -0
- package/dist/emf-defaults.d.ts +651 -0
- package/dist/emf-defaults.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +531 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.d.ts +56 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/reference-resolver.d.ts +28 -0
- package/dist/reference-resolver.d.ts.map +1 -0
- package/dist/type-discriminator.d.ts +14 -0
- package/dist/type-discriminator.d.ts.map +1 -0
- package/package.json +50 -0
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Application } from '@judo/model-api';
|
|
2
|
+
/**
|
|
3
|
+
* Parse options for advanced use cases.
|
|
4
|
+
*/
|
|
5
|
+
export interface ParseOptions {
|
|
6
|
+
/** Validate references after parsing */
|
|
7
|
+
validateReferences?: boolean;
|
|
8
|
+
/** Include raw XML attributes for debugging */
|
|
9
|
+
preserveRawAttributes?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse error information.
|
|
13
|
+
*/
|
|
14
|
+
export interface ParseError {
|
|
15
|
+
type: "MISSING_REFERENCE" | "INVALID_TYPE" | "MISSING_REQUIRED";
|
|
16
|
+
message: string;
|
|
17
|
+
elementId?: string;
|
|
18
|
+
referencedId?: string;
|
|
19
|
+
path: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extended parse result with metadata.
|
|
23
|
+
*/
|
|
24
|
+
export interface ParseResult {
|
|
25
|
+
applications: Application[];
|
|
26
|
+
/** All elements indexed by xmi:id for reference resolution */
|
|
27
|
+
elementIndex: Map<string, unknown>;
|
|
28
|
+
/** Validation errors if validateReferences=true */
|
|
29
|
+
errors: ParseError[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse an XMI/XML model string into Application objects.
|
|
33
|
+
* Returns array for multi-actor model support.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseModel(xml: string): Application[];
|
|
36
|
+
/**
|
|
37
|
+
* Parse with options for advanced use cases.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseModelWithOptions(xml: string, options?: ParseOptions): ParseResult;
|
|
40
|
+
/**
|
|
41
|
+
* Error thrown when model parsing fails.
|
|
42
|
+
*/
|
|
43
|
+
export declare class ModelParseError extends Error {
|
|
44
|
+
readonly path: string;
|
|
45
|
+
readonly cause?: Error | undefined;
|
|
46
|
+
constructor(message: string, path: string, cause?: Error | undefined);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when a reference cannot be resolved.
|
|
50
|
+
*/
|
|
51
|
+
export declare class ModelReferenceError extends Error {
|
|
52
|
+
readonly sourceId: string;
|
|
53
|
+
readonly targetRef: string;
|
|
54
|
+
constructor(sourceId: string, targetRef: string);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAYnD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,wCAAwC;IACxC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,+CAA+C;IAC/C,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,mBAAmB,GAAG,cAAc,GAAG,kBAAkB,CAAC;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,8DAA8D;IAC9D,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,mDAAmD;IACnD,MAAM,EAAE,UAAU,EAAE,CAAC;CACrB;AA6UD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,CAOrD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,WAAW,CAyB1F;AA8DD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aAGxB,IAAI,EAAE,MAAM;aACZ,KAAK,CAAC,EAAE,KAAK;gBAF7B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,KAAK,YAAA;CAK9B;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aAE5B,QAAQ,EAAE,MAAM;aAChB,SAAS,EAAE,MAAM;gBADjB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM;CAKlC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference resolver for XMI cross-references.
|
|
3
|
+
* Indexes elements by xmi:id during first pass and resolves references in second pass.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ReferenceResolver {
|
|
6
|
+
private index;
|
|
7
|
+
/**
|
|
8
|
+
* Index an element by its xmi:id.
|
|
9
|
+
*/
|
|
10
|
+
indexElement(element: Record<string, unknown>): void;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a reference string to the indexed element.
|
|
13
|
+
*/
|
|
14
|
+
resolve<T = unknown>(ref: string): T | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get all indexed elements.
|
|
17
|
+
*/
|
|
18
|
+
getIndex(): Map<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* Clear the index.
|
|
21
|
+
*/
|
|
22
|
+
clear(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Index all elements in a tree recursively.
|
|
25
|
+
*/
|
|
26
|
+
indexTree(element: unknown): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=reference-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-resolver.d.ts","sourceRoot":"","sources":["../src/reference-resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,KAAK,CAA8B;IAE3C;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAOpD;;OAEG;IACH,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIhD;;OAEG;IACH,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAIhC;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAyBjC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XMI type map: maps xsi:type values to simplified type names.
|
|
3
|
+
*/
|
|
4
|
+
export declare const TYPE_MAP: Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Discriminate type from XMI element.
|
|
7
|
+
* Uses xsi:type attribute or infers from element structure.
|
|
8
|
+
*/
|
|
9
|
+
export declare function discriminateType(element: Record<string, unknown>): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Infer type from element tag name when xsi:type is not present.
|
|
12
|
+
*/
|
|
13
|
+
export declare function inferTypeFromTag(tagName: string): string | undefined;
|
|
14
|
+
//# sourceMappingURL=type-discriminator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-discriminator.d.ts","sourceRoot":"","sources":["../src/type-discriminator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA+F3C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAWrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAwBpE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@judo/model-parser",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "XMI/XML parser for JUDO UI models",
|
|
5
|
+
"license": "EPL-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/BlackBeltTechnology/judo-frontend-runtime.git",
|
|
9
|
+
"directory": "packages/model-parser"
|
|
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
|
+
"import": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@judo/model-api": "0.1.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^25.2.3",
|
|
34
|
+
"fast-xml-parser": "^5.3.6",
|
|
35
|
+
"typescript": "^5.9.3",
|
|
36
|
+
"vitest": "^4.0.18",
|
|
37
|
+
"@judo/model-api": "0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"fast-xml-parser": "^5.3.6",
|
|
41
|
+
"@judo/model-api": "0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "vite build",
|
|
45
|
+
"clean": "rm -rf dist",
|
|
46
|
+
"type-check": "tsgo --noEmit",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:watch": "vitest"
|
|
49
|
+
}
|
|
50
|
+
}
|