Skip to content

Commit

Permalink
chore(build): Merge xml-schema-ts package into kaoto
Browse files Browse the repository at this point in the history
  • Loading branch information
lordrip committed Dec 9, 2024
1 parent 665b146 commit 80b2856
Show file tree
Hide file tree
Showing 145 changed files with 69 additions and 713 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

# Build packages excluding @kaoto/camel-catalog since it was build during installing dependencies
- name: Build packages
run: yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog --exclude @kaoto/xml-schema-ts run build
run: yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog run build

# Run tests
- name: 🧪 Run tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
# Build packages excluding @kaoto/camel-catalog since it was build during installing dependencies
- name: '🔧 Build packages'
run: |
yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog --exclude @kaoto/xml-schema-ts run build
yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog run build
- name: '🔧 Tar UI Dist'
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

# Build packages excluding @kaoto/camel-catalog since it was build during installing dependencies
- name: Build packages
run: yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog --exclude @kaoto/xml-schema-ts run build
run: yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog run build

# Build lib
- name: Build @kaoto/kaoto package in lib mode
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:

- name: '🔧 Build packages'
run: |
yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog --exclude @kaoto/xml-schema-ts run build
yarn workspaces foreach --verbose --all --topological-dev --exclude @kaoto/camel-catalog run build
- name: '🛰️ Login to Container Registry'
uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"typescript": "5.5.4"
},
"scripts": {
"postinstall": "yarn workspace @kaoto/camel-catalog run build && yarn workspace @kaoto/xml-schema-ts run build",
"postinstall": "yarn workspace @kaoto/camel-catalog run build",
"version": "lerna version",
"publish": "lerna publish from-package"
},
Expand Down
1 change: 0 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"dependencies": {
"@dnd-kit/core": "^6.1.0",
"@kaoto-next/uniforms-patternfly": "^0.7.14",
"@kaoto/xml-schema-ts": "workspace:*",
"@kie-tools-core/editor": "0.32.0",
"@kie-tools-core/notifications": "0.32.0",
"@types/uuid": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/services/xml-schema-document.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
XmlSchemaSimpleType,
XmlSchemaType,
XmlSchemaUse,
} from '@kaoto/xml-schema-ts';
} from '../xml-schema-ts';
import { BaseDocument, BaseField, ITypeFragment } from '../models/datamapper/document';
import { Types } from '../models/datamapper/types';
import { DocumentType } from '../models/datamapper/path';
Expand Down
23 changes: 12 additions & 11 deletions packages/ui/src/stubs/data-mapper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { parse } from 'yaml';
import { DATAMAPPER_ID_PREFIX, XSLT_COMPONENT_NAME } from '../utils';
import fs from 'fs';
import { XmlSchemaDocumentService } from '../services/xml-schema-document.service';
import { DocumentType } from '../models/datamapper/path';
import path from 'path';
import { parse } from 'yaml';
import { IDocument, PrimitiveDocument } from '../models/datamapper/document';
import { DocumentType } from '../models/datamapper/path';
import { XmlSchemaDocumentService } from '../services/xml-schema-document.service';
import { DATAMAPPER_ID_PREFIX, XSLT_COMPONENT_NAME } from '../utils';

export const datamapperRouteDefinitionStub = parse(`
from:
Expand All @@ -18,25 +19,25 @@ export const datamapperRouteDefinitionStub = parse(`
uri: ${XSLT_COMPONENT_NAME}:transform.xsl`);

export const shipOrderXsd = fs
.readFileSync(__dirname + '/../../../xml-schema-ts/test-resources/ShipOrder.xsd')
.readFileSync(path.resolve(__dirname, '../xml-schema-ts/test-resources/ShipOrder.xsd'))
.toString();
export const testDocumentXsd = fs
.readFileSync(__dirname + '/../../../xml-schema-ts/test-resources/TestDocument.xsd')
.readFileSync(path.resolve(__dirname, '../xml-schema-ts/test-resources/TestDocument.xsd'))
.toString();
export const noTopElementXsd = fs
.readFileSync(__dirname + '/../../../xml-schema-ts/test-resources/NoTopElement.xsd')
.readFileSync(path.resolve(__dirname, '../xml-schema-ts/test-resources/NoTopElement.xsd'))
.toString();
export const camelSpringXsd = fs
.readFileSync(__dirname + '/../../../xml-schema-ts/test-resources/camel-spring.xsd')
.readFileSync(path.resolve(__dirname, '../xml-schema-ts/test-resources/camel-spring.xsd'))
.toString();
export const shipOrderToShipOrderXslt = fs
.readFileSync(__dirname + '/../../../xml-schema-ts/test-resources/ShipOrderToShipOrder.xsl')
.readFileSync(path.resolve(__dirname, '../xml-schema-ts/test-resources/ShipOrderToShipOrder.xsl'))
.toString();
export const shipOrderToShipOrderInvalidForEachXslt = fs
.readFileSync(__dirname + '/../../../xml-schema-ts/test-resources/ShipOrderToShipOrderInvalidForEach.xsl')
.readFileSync(path.resolve(__dirname, '../xml-schema-ts/test-resources/ShipOrderToShipOrderInvalidForEach.xsl'))
.toString();
export const shipOrderEmptyFirstLineXsd = fs
.readFileSync(__dirname + '/../../../xml-schema-ts/test-resources/ShipOrderEmptyFirstLine.xsd')
.readFileSync(path.resolve(__dirname, '../xml-schema-ts/test-resources/ShipOrderEmptyFirstLine.xsd'))
.toString();

export class TestUtil {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { XmlSchemaCollection } from './XmlSchemaCollection';
import fs from 'fs';
import path from 'path';
import { QName } from './QName';
import { XmlSchemaComplexType } from './complex/XmlSchemaComplexType';
import { XmlSchemaAttribute } from './attribute/XmlSchemaAttribute';
import { XmlSchemaCollection } from './XmlSchemaCollection';
import { XmlSchemaUse } from './XmlSchemaUse';
import { XmlSchemaSequence } from './particle/XmlSchemaSequence';
import { XmlSchemaElement } from './particle/XmlSchemaElement';
import { XmlSchemaAttribute } from './attribute/XmlSchemaAttribute';
import { XmlSchemaAttributeGroupRef } from './attribute/XmlSchemaAttributeGroupRef';
import { XmlSchemaSimpleType } from './simple/XmlSchemaSimpleType';
import { screen } from '@testing-library/react';
import { XmlSchemaComplexContentExtension } from './complex/XmlSchemaComplexContentExtension';
import { XmlSchemaComplexType } from './complex/XmlSchemaComplexType';
import { XmlSchemaElement } from './particle/XmlSchemaElement';
import { XmlSchemaSequence } from './particle/XmlSchemaSequence';
import { XmlSchemaSimpleType } from './simple/XmlSchemaSimpleType';

describe('XmlSchemaCollection', () => {
const orderXsd = fs.readFileSync(__dirname + '/../test-resources/ShipOrder.xsd').toString();
const testXsd = fs.readFileSync(__dirname + '/../test-resources/TestDocument.xsd').toString();
const namedTypesXsd = fs.readFileSync(__dirname + '/../test-resources/NamedTypes.xsd').toString();
const camelSpringXsd = fs.readFileSync(__dirname + '/../test-resources/camel-spring.xsd').toString();
const orderXsd = fs.readFileSync(path.resolve(__dirname, 'test-resources/ShipOrder.xsd')).toString();
const testXsd = fs.readFileSync(path.resolve(__dirname, 'test-resources/TestDocument.xsd')).toString();
const namedTypesXsd = fs.readFileSync(path.resolve(__dirname, 'test-resources/NamedTypes.xsd')).toString();
const camelSpringXsd = fs.readFileSync(path.resolve(__dirname, 'test-resources/camel-spring.xsd')).toString();
const orderXsdEmptyFirstLine = fs
.readFileSync(__dirname + '/../test-resources/ShipOrderEmptyFirstLine.xsd')
.readFileSync(path.resolve(__dirname, 'test-resources/ShipOrderEmptyFirstLine.xsd'))
.toString();

it('should parse ShipOrder XML schema', () => {
Expand Down Expand Up @@ -111,7 +111,6 @@ describe('XmlSchemaCollection', () => {
const element1SequenceMembers = element1Sequence.getItems();
expect(element1SequenceMembers.length).toEqual(1);
const element1Simple1 = element1SequenceMembers[0] as XmlSchemaElement;
const element1Simple1SchemaType = element1Simple1.getSchemaType();
expect(element1Simple1.getWireName()?.getNamespaceURI()).toEqual('');
expect(element1Simple1.getWireName()?.getLocalPart()).toEqual('Element1Simple1');
});
Expand All @@ -136,7 +135,8 @@ describe('XmlSchemaCollection', () => {
try {
collection.read(orderXsdEmptyFirstLine, () => {});
} catch (error) {
expect(error.message).toContain('an XML declaration must be at the start of the document');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((error as any).message).toContain('an XML declaration must be at the start of the document');
return;
}
fail('No error was thrown');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ export class XmlSchemaCollection {
return null;
}
const uri = name.getNamespaceURI();
const entries = this.schemas.entries();
for (const entry of Array.from(this.schemas.entries())) {
if (entry[0].getNamespace() === uri) {
const group = entry[1].getAttributeGroupByQName(name);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
export { QNameMap } from './utils/ObjectMap';
export { XmlSchema } from './XmlSchema';
export { XmlSchemaAll } from './particle/XmlSchemaAll';
export { XmlSchemaAny } from './particle/XmlSchemaAny';
export { XmlSchemaAllMember } from './particle/XmlSchemaAllMember';
export { XmlSchemaAttribute } from './attribute/XmlSchemaAttribute';
export { XmlSchemaAttributeGroup } from './attribute/XmlSchemaAttributeGroup';
export { XmlSchemaAttributeGroupMember } from './attribute/XmlSchemaAttributeGroupMember';
export { XmlSchemaAttributeGroupRef } from './attribute/XmlSchemaAttributeGroupRef';
export { XmlSchemaAttributeOrGroupRef } from './attribute/XmlSchemaAttributeOrGroupRef';
export { XmlSchemaChoice } from './particle/XmlSchemaChoice';
export { XmlSchemaChoiceMember } from './particle/XmlSchemaChoiceMember';
export { XmlSchemaCollection } from './XmlSchemaCollection';
export { XmlSchemaComplexContentExtension } from './complex/XmlSchemaComplexContentExtension';
export { XmlSchemaComplexContentRestriction } from './complex/XmlSchemaComplexContentRestriction';
export { XmlSchemaComplexType } from './complex/XmlSchemaComplexType';
export { XmlSchemaContentModel } from './XmlSchemaContentModel';
export { XmlSchemaAll } from './particle/XmlSchemaAll';
export { XmlSchemaAny } from './particle/XmlSchemaAny';
export { XmlSchemaChoice } from './particle/XmlSchemaChoice';
export { XmlSchemaElement } from './particle/XmlSchemaElement';
export { XmlSchemaGroup } from './XmlSchemaGroup';
export { XmlSchemaGroupParticle } from './particle/XmlSchemaGroupParticle';
export { XmlSchemaGroupRef } from './particle/XmlSchemaGroupRef';
export { XmlSchemaObjectBase } from './utils/XmlSchemaObjectBase';
export { XmlSchemaParticle } from './particle/XmlSchemaParticle';
export { XmlSchemaRef } from './utils/XmlSchemaRef';
export { XmlSchemaSequence } from './particle/XmlSchemaSequence';
export { XmlSchemaSequenceMember } from './particle/XmlSchemaSequenceMember';
export { XmlSchemaSimpleContentExtension } from './simple/XmlSchemaSimpleContentExtension';
export { XmlSchemaSimpleContentRestriction } from './simple/XmlSchemaSimpleContentRestriction';
export { XmlSchemaSimpleType } from './simple/XmlSchemaSimpleType';
export { QNameMap } from './utils/ObjectMap';
export { XmlSchemaRef } from './utils/XmlSchemaRef';
export { XmlSchema } from './XmlSchema';
export { XmlSchemaCollection } from './XmlSchemaCollection';
export { XmlSchemaContentModel } from './XmlSchemaContentModel';
export { XmlSchemaGroup } from './XmlSchemaGroup';
export { XmlSchemaType } from './XmlSchemaType';
export { XmlSchemaUse } from './XmlSchemaUse';

export type { XmlSchemaAttributeGroupMember } from './attribute/XmlSchemaAttributeGroupMember';
export type { XmlSchemaAllMember } from './particle/XmlSchemaAllMember';
export type { XmlSchemaChoiceMember } from './particle/XmlSchemaChoiceMember';
export type { XmlSchemaSequenceMember } from './particle/XmlSchemaSequenceMember';
export type { XmlSchemaObjectBase } from './utils/XmlSchemaObjectBase';
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as fs from 'fs';
import fs from 'fs';
import path from 'path';

describe.skip('XML parser', () => {
describe('DOMParser', () => {
const parser = new DOMParser();

it('should parse XML schema', () => {
const orderXsd = fs.readFileSync(__dirname + '/../../../../test-resources/ShipOrder.xsd').toString();
const orderXsd = fs.readFileSync(path.resolve(__dirname, 'test-resources/ShipOrder.xsd')).toString();
const xmlDoc = parser.parseFromString(orderXsd, 'text/xml');
expect(xmlDoc).toBeDefined();
const schema = xmlDoc.getElementsByTagName('xs:schema')[0];
Expand All @@ -22,7 +23,7 @@ describe.skip('XML parser', () => {
});

it('should parse XML document', () => {
const orderXml = fs.readFileSync(__dirname + '/../../../../test-resources/ExampleOrder.xml').toString();
const orderXml = fs.readFileSync(path.resolve(__dirname, 'test-resources/ExampleOrder.xml')).toString();
const xmlDoc = parser.parseFromString(orderXml, 'text/xml');
expect(xmlDoc).toBeDefined();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"target": "ES5",
"target": "ES2020",
"outDir": "lib/cjs",
},
}
3 changes: 0 additions & 3 deletions packages/xml-schema-ts/.lintstagedrc.json

This file was deleted.

16 changes: 0 additions & 16 deletions packages/xml-schema-ts/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions packages/xml-schema-ts/babel.config.cjs

This file was deleted.

48 changes: 0 additions & 48 deletions packages/xml-schema-ts/jest.config.js

This file was deleted.

20 changes: 0 additions & 20 deletions packages/xml-schema-ts/jest.setup.ts

This file was deleted.

46 changes: 0 additions & 46 deletions packages/xml-schema-ts/package.json

This file was deleted.

Loading

0 comments on commit 80b2856

Please sign in to comment.