Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into kie-issues-172
Browse files Browse the repository at this point in the history
  • Loading branch information
ljmotta committed Sep 28, 2023
2 parents 9cf1cff + cb1635e commit 3547092
Show file tree
Hide file tree
Showing 211 changed files with 1,715 additions and 8,686 deletions.
83 changes: 83 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Apache KIE
Copyright 2023 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

The Initial Developer of some parts of the framework, which are copied from, derived from, or
inspired by KIE (Knowledge Is Everthing) group, is Red Hat, Inc (https://www.redhat.com/).
Copyright Red Hat, Inc. and/or its affiliates.. All Rights Reserved.

This product also includes the following third-party components:

* animate.css (http://daneden.me/animate)

Copyright (c) 2016 Daniel Eden

* bootstrap (https://getbootstrap.com/)

Copyright 2011-2019 Twitter, Inc.

* bootstrap-datepicker (https://github.com/smalot/bootstrap-datetimepicker)

Copyright 2012 Stefan Petre

* bootstrap-select (http://silviomoreto.github.io/bootstrap-select)

Copyright 2013-2017 bootstrap-select

* Context Dependency Injection (CDI)

Copyright (C) 2009 The JSR-330 Expert Group

* connected (https://github.com/Vertispan/connected)

Copyright (C) 2017 Vertispan

* Eclipse Modeling Framework (https://eclipse.dev/modeling/emf/)

Copyright (C) Eclipse and contributors: Copyright (c) 2010 SAP AG

* Font Awesome (https://fontawesome.com/)

Copyright Dave Gandy 2016. All rights reserved

* Google Web Toolkit (GWT) (https://www.gwtproject.org/)

Copyright 2007 Google Inc.

* GWT Bootstrap 3 (https://github.com/gwtbootstrap3/gwtbootstrap3)

Copyright (C) 2013 GwtBootstrap3

* Jakarta EE (https://jakarta.ee/)

Copyright (C) Eclipse and contributors

* Java Enterprise Edition (https://www.oracle.com/java/technologies/java-ee-glance.html)

Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.

* Java Standard Edition (https://www.gwtproject.org/)

Copyright (c) 2005-2013 Oracle and/or its affiliates

* jQuery UI (http://jqueryui.com)

Copyright jQuery Foundation

* libgdx (https://github.com/libgdx/libgdx)

Copyright (c) 2008, Avian Contributors

* Lienzo (https://github.com/dikalo/lienzo-core)

Copyright (c) 2017 Ahome' Innovation Technologies

* Respond.js (https://github.com/scottjehl/Respond)

Copyright 2013 Scott Jehl

* SnakeYAML (https://bitbucket.org/snakeyaml/snakeyaml)

Copyright (c) 2018, SnakeYAML
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@kie-tools-core/notifications": "workspace:*",
"@kie-tools-core/workspace": "workspace:*",
"axios": "^0.27.2",
"fast-xml-parser": "^4.2.4",
"fast-xml-parser": "^4.3.1",
"portfinder": "^1.0.32",
"semver": "^7.5.4",
"sinon": "^11.1.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
/*
* Copyright 2019 JBoss Inc
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.uberfire.ext.widgets.common.client.tables;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* * Copyright 2015 JBoss Inc
* *
* * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* * use this file except in compliance with the License. You may obtain a copy of
* * the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* * License for the specific language governing permissions and limitations under
* * the License.
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.uberfire.annotations.processors;
Expand Down
10 changes: 5 additions & 5 deletions packages/feel-input-component/src/FeelConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export const feelTokensConfig = (): Monaco.languages.IMonarchLanguage => {
functions: Array.from(ReservedWords.FeelFunctions),
tokenizer: {
root: [
[/(?:true|false)/, "feel-boolean"],
[/[0-9]+/, "feel-numeric"],
[/(?:"(?:.*?)")/, "feel-string"],
[/([a-z{1}][a-z_\s]*[a-z$])(?=\()/, { cases: { "@functions": "feel-function" } }],
[/[\w$]*[a-z_$][\w$]*/, { cases: { "@keywords": "feel-keyword" } }],
[/(?:true|false)/, Element[Element.FeelBoolean]],
[/[0-9]+/, Element[Element.FeelNumeric]],
[/(?:"(?:.*?)")/, Element[Element.FeelString]],
[/([a-z{1}][a-z_\s]*[a-z$])(?=\()/, { cases: { "@functions": Element[Element.FeelFunction] } }],
[/[\w$]*[a-z_$][\w$]*/, { cases: { "@keywords": Element[Element.FeelKeyword] } }],
],
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as fs from "../../generation/fs";
import { FormAsset, FormGenerationTool, FormSchema } from "../../generation/types";
import { ApplyForVisaSchema, ConfirmTravelSchema } from "./tools/uniforms/patternfly/mock";
import { registerFormGenerationTool } from "../../generation/tools";
import { inputSanitizationUtil } from "../../generation/tools/uniforms/utils/InputSanitizationUtil";

jest.mock("../../generation/fs");

Expand Down Expand Up @@ -62,7 +63,7 @@ describe("formGenerationCommand tests", () => {
it("Generate forms project with schemas", () => {
const schemas: FormSchema[] = [
{
name: "ApplyForVisa",
name: "Apply#For#Visa",
schema: ApplyForVisaSchema,
},
{
Expand All @@ -83,15 +84,19 @@ describe("formGenerationCommand tests", () => {
expect(storeFormAssetsMock).toBeCalledTimes(2);

const applyForVisaAsset: FormAsset = storeFormAssetsMock.mock.calls[0][0];
expect(applyForVisaAsset.id).toEqual("ApplyForVisa");
expect(applyForVisaAsset.assetName).toEqual("ApplyForVisa.tsx");
expect(applyForVisaAsset.content).toContain("const Form__ApplyForVisa");
expect(applyForVisaAsset.id).toEqual("Apply#For#Visa");
expect(applyForVisaAsset.sanitizedId).toEqual("Apply_For_Visa");
expect(applyForVisaAsset.assetName).toEqual("Apply#For#Visa.tsx");
expect(applyForVisaAsset.sanitizedAssetName).toEqual("Apply_For_Visa.tsx");
expect(applyForVisaAsset.content).toContain("const Form__Apply_For_Visa");
expect(storeFormAssetsMock.mock.calls[0][1]).toEqual(sourcePath);
expect(storeFormAssetsMock.mock.calls[0][2]).toBeTruthy();

const confirmTravelAsset: FormAsset = storeFormAssetsMock.mock.calls[1][0];
expect(confirmTravelAsset.id).toEqual("ConfirmTravel");
expect(confirmTravelAsset.sanitizedId).toEqual("ConfirmTravel");
expect(confirmTravelAsset.assetName).toEqual("ConfirmTravel.tsx");
expect(confirmTravelAsset.sanitizedAssetName).toEqual("ConfirmTravel.tsx");
expect(confirmTravelAsset.content).toContain("const Form__ConfirmTravel");
expect(storeFormAssetsMock.mock.calls[1][1]).toEqual(sourcePath);
expect(storeFormAssetsMock.mock.calls[1][2]).toBeTruthy();
Expand All @@ -110,9 +115,11 @@ describe("formGenerationCommand tests", () => {

return {
id: schema.name,
sanitizedId: inputSanitizationUtil(schema.name),
content: schema.name,
type: "txt",
assetName: `${schema.name}.txt`,
sanitizedAssetName: `${inputSanitizationUtil(schema.name)}.txt`,
config: {
schema: "",
resources: { styles: {}, scripts: {} },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ describe("storeFormAssets tests", () => {
const sourcePath = "/a/test/path";
const formAsset: FormAsset = {
id: "test",
sanitizedId: "test",
assetName: "test.tsx",
sanitizedAssetName: "test.tsx",
type: FormAssetType.TSX,
content: "content",
config: new PatternflyFormConfig({}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ describe("Bootstrap4FormGenerationTool tests", () => {
const tool = new Bootstrap4FormGenerationTool();

const formAsset: FormAsset = tool.generate({
name: "ApplyForVisa",
name: "ApplyFor#Visa",
schema: ApplyForVisaSchema,
});

expect(formAsset).not.toBeUndefined();
expect(formAsset.id).toStrictEqual("ApplyForVisa");
expect(formAsset.assetName).toStrictEqual("ApplyForVisa.html");
expect(formAsset.id).toStrictEqual("ApplyFor#Visa");
expect(formAsset.sanitizedId).toStrictEqual("ApplyFor_Visa");
expect(formAsset.assetName).toStrictEqual("ApplyFor#Visa.html");
expect(formAsset.sanitizedAssetName).toStrictEqual("ApplyFor_Visa.html");
expect(formAsset.content).not.toBeUndefined();
expect(formAsset.config).not.toBeUndefined();
expect(formAsset.config).toMatchObject(new Bootstrap4FormConfig(ApplyForVisaSchema));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ describe("PatternflyFormGenerationTool tests", () => {
const tool = new PatternflyFormGenerationTool();

const formAsset: FormAsset = tool.generate({
name: "ApplyForVisa",
name: "ApplyFor#Visa",
schema: ApplyForVisaSchema,
});

expect(formAsset).not.toBeUndefined();
expect(formAsset.id).toStrictEqual("ApplyForVisa");
expect(formAsset.assetName).toStrictEqual("ApplyForVisa.tsx");
expect(formAsset.id).toStrictEqual("ApplyFor#Visa");
expect(formAsset.sanitizedId).toStrictEqual("ApplyFor_Visa");
expect(formAsset.assetName).toStrictEqual("ApplyFor#Visa.tsx");
expect(formAsset.sanitizedAssetName).toStrictEqual("ApplyFor_Visa.tsx");
expect(formAsset.content).not.toBeUndefined();
expect(formAsset.content).toContain("const Form__ApplyForVisa");
expect(formAsset.content).toContain("export default Form__ApplyForVisa;");
expect(formAsset.content).toContain("const Form__ApplyFor_Visa");
expect(formAsset.content).toContain("export default Form__ApplyFor_Visa;");
expect(formAsset.config).not.toBeUndefined();
expect(formAsset.config).toMatchObject(new PatternflyFormConfig(ApplyForVisaSchema));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function generateForms({ path, type, overwrite }: Args) {
console.log(`\nGenerating form "${form.name}"`);
const output: FormAsset = tool.generate(form);
storeFormAsset(output, path, overwrite);
console.log(`Successfully generated form "${output.assetName}"`);
console.log(`Successfully generated form "${output.sanitizedAssetName}"`);
} catch (err) {
console.log(`Cannot generate form "${form.name}": `, err.message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function getFormAssetPath(sourcePath: string, formAsset: string): string
}

export function getFormConfigAssetPath(source: string, formAsset: FormAsset): string {
return getFormAssetPath(source, `${formAsset.id}${FORM_CONFIG_EXT}`);
return getFormAssetPath(source, `${formAsset.sanitizedId}${FORM_CONFIG_EXT}`);
}

export function storeFormAsset(formAsset: FormAsset, source: string, overwriteExisting: boolean) {
Expand All @@ -45,20 +45,20 @@ export function storeFormAsset(formAsset: FormAsset, source: string, overwriteEx

const existingFormAssets = fs.readdirSync(storagePath).filter((file) => {
const extension = path.extname(file);
return path.basename(file, extension) === formAsset.id;
return path.basename(file, extension) === formAsset.sanitizedId;
});

if (existingFormAssets.length > 0) {
if (!overwriteExisting) {
throw new Error(`Form already exists.`);
}

console.log(`Form "${formAsset.id}" already exists. Proceeding to overwrite it.`);
console.log(`Form "${formAsset.sanitizedId}" already exists. Proceeding to overwrite it.`);

existingFormAssets.forEach((file) => {
fs.rmSync(getFormAssetPath(source, file));
});
}
fs.writeFileSync(getFormAssetPath(source, formAsset.assetName), formAsset.content);
fs.writeFileSync(getFormAssetPath(source, formAsset.sanitizedAssetName), formAsset.content);
fs.writeFileSync(getFormConfigAssetPath(source, formAsset), JSON.stringify(formAsset.config, null, 4));
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { FormAssetType, FormAsset, FormStyle, FormConfig, FormGenerationTool, Fo
import { renderForm } from "@kie-tools/uniforms-bootstrap4-codegen/dist";
import JSONSchemaBridge from "uniforms-bridge-json-schema";
import { getUniformsSchema } from "../utils/UniformsSchemaUtils";
import { inputSanitizationUtil } from "../utils/InputSanitizationUtil";

export const BOOTSTRAP4_CSS_URL = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css";
export const BOOTSTRAP4_JS_URL = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.bundle.min.js";
Expand Down Expand Up @@ -55,13 +56,16 @@ export class Bootstrap4FormGenerationTool implements FormGenerationTool {

const form = renderForm({
id: inputSchema.name,
sanitizedId: inputSanitizationUtil(inputSchema.name),
schema: new JSONSchemaBridge(uniformsSchema, () => true),
disabled: false,
placeholder: true,
});
return {
id: inputSchema.name,
sanitizedId: inputSanitizationUtil(inputSchema.name),
assetName: `${inputSchema.name}.${FormAssetType.HTML}`,
sanitizedAssetName: `${inputSanitizationUtil(inputSchema.name)}.${FormAssetType.HTML}`,
type: FormAssetType.HTML,
content: unescape(form),
config: new Bootstrap4FormConfig(inputSchema.schema),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { FormAssetType, FormAsset, FormStyle, FormConfig, FormGenerationTool, Fo
import { renderForm } from "@kie-tools/uniforms-patternfly-codegen/dist";
import JSONSchemaBridge from "uniforms-bridge-json-schema";
import { getUniformsSchema } from "../utils/UniformsSchemaUtils";
import { inputSanitizationUtil } from "../utils/InputSanitizationUtil";

export class PatternflyFormConfig implements FormConfig {
public readonly schema: string;
Expand All @@ -44,13 +45,16 @@ export class PatternflyFormGenerationTool implements FormGenerationTool {
const uniformsSchema = getUniformsSchema(inputSchema.schema);
const form = renderForm({
id: inputSchema.name,
sanitizedId: inputSanitizationUtil(inputSchema.name),
schema: new JSONSchemaBridge(uniformsSchema, () => true),
disabled: false,
placeholder: true,
});
return {
id: inputSchema.name,
sanitizedId: inputSanitizationUtil(inputSchema.name),
assetName: `${inputSchema.name}.${FormAssetType.TSX}`,
sanitizedAssetName: `${inputSanitizationUtil(inputSchema.name)}.${FormAssetType.TSX}`,
type: FormAssetType.TSX,
content: unescape(form),
config: new PatternflyFormConfig(inputSchema.schema),
Expand Down
Loading

0 comments on commit 3547092

Please sign in to comment.