commit eed3b364b1f012a0aed1cf44a0c669b139879476 Author: YUKI VACHOT Date: Wed Jun 5 10:18:10 2024 +0200 Initial commit diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..812ab5a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..03b6a3c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/palantir_schema_changes.iml b/.idea/palantir_schema_changes.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/palantir_schema_changes.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..33d6687 --- /dev/null +++ b/index.html @@ -0,0 +1,38 @@ + + + + + + Palantir Foundry - Schema Comparison Tool (New and Old) + + + +
+

Palantir Foundry - Schema Comparison Tool (New and Old)

+
+ Help: +

Ensure your text follows this format:

+
+{message=New schema is incompatible with old schema, newSchema=FoundrySchema{fieldSchemaList=[FoundryFieldSchema{...}], oldSchema=FoundrySchema{fieldSchemaList=[FoundryFieldSchema{...}]}}
+            
+
+ + + +
+ + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..be013a7 --- /dev/null +++ b/script.js @@ -0,0 +1,76 @@ +function compareSchemas() { + const text = document.getElementById("schemaText").value; + const result = parseSchemas(text); + if (result) { + displayResult(result); + } +} + +function parseSchemas(text) { + const oldSchemaMatch = text.match(/oldSchema=FoundrySchema\{fieldSchemaList=\[(.*?)\], dataFrameReaderClass/s); + const newSchemaMatch = text.match(/newSchema=FoundrySchema\{fieldSchemaList=\[(.*?)\], dataFrameReaderClass/s); + + if (!oldSchemaMatch || !newSchemaMatch) { + alert("Invalid input. Please ensure the text contains both old and new schema definitions."); + return null; + } + + const oldSchema = parseFields(oldSchemaMatch[1]); + const newSchema = parseFields(newSchemaMatch[1]); + + const added = newSchema.filter(field => !oldSchema.some(oldField => oldField.name === field.name)); + const removed = oldSchema.filter(field => !newSchema.some(newField => newField.name === field.name)); + const modified = newSchema.filter(field => { + const oldField = oldSchema.find(oldField => oldField.name === field.name); + return oldField && JSON.stringify(oldField) !== JSON.stringify(field); + }); + + return { added, removed, modified }; +} + +function parseFields(fieldsText) { + return fieldsText.split('FoundryFieldSchema{').slice(1).map(fieldText => { + const nameMatch = fieldText.match(/name: Optional\[(.*?)\]/); + const typeMatch = fieldText.match(/type: (\w+)/); + const nullableMatch = fieldText.match(/nullable: (\w+)/); + const userDefinedTypeClassMatch = fieldText.match(/userDefinedTypeClass: (\w+)/); + + return { + name: nameMatch ? nameMatch[1] : null, + type: typeMatch ? typeMatch[1] : null, + nullable: nullableMatch ? nullableMatch[1] : null, + userDefinedTypeClass: userDefinedTypeClassMatch ? userDefinedTypeClassMatch[1] : null + }; + }); +} + +function displayResult(result) { + document.getElementById("result").style.display = "block"; + + const addedTable = document.getElementById("addedTable"); + const removedTable = document.getElementById("removedTable"); + const modifiedTable = document.getElementById("modifiedTable"); + + populateTable(addedTable, result.added); + populateTable(removedTable, result.removed); + populateTable(modifiedTable, result.modified); +} + +function populateTable(table, data) { + table.innerHTML = ` + + Name + Type + Nullable + User Defined Type Class + + `; + + data.forEach(field => { + const row = table.insertRow(); + row.insertCell(0).textContent = field.name; + row.insertCell(1).textContent = field.type; + row.insertCell(2).textContent = field.nullable; + row.insertCell(3).textContent = field.userDefinedTypeClass; + }); +} diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..2381d84 --- /dev/null +++ b/styles.css @@ -0,0 +1,84 @@ +body { + font-family: Arial, sans-serif; + background-color: #f5f5f5; + margin: 0; + padding: 0; + display: flex; + justify-content: center; + align-items: flex-start; + height: 100vh; +} + +.container { + background-color: #fff; + padding: 20px; + border-radius: 8px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + width: 80%; + max-width: 1000px; + margin-top: 20px; +} + +h1, h2, h3 { + text-align: center; + margin: 0; + padding: 10px 0; +} + +textarea { + width: 100%; + height: 150px; + margin: 10px 0; + padding: 10px; + font-size: 14px; + border: 1px solid #ccc; + border-radius: 4px; + resize: vertical; +} + +button { + width: 100%; + padding: 10px; + font-size: 16px; + color: #fff; + background-color: #007bff; + border: none; + border-radius: 4px; + cursor: pointer; + margin-bottom: 20px; +} + +button:hover { + background-color: #0056b3; +} + +pre { + background-color: #f0f0f0; + padding: 10px; + border-radius: 4px; + overflow-x: auto; +} + +#helpPanel { + margin-top: 20px; + padding: 10px; + border: 1px solid #ddd; + background: #f9f9f9; +} + +table { + width: 100%; + border-collapse: collapse; + margin-bottom: 20px; +} +th, td { + border: 1px solid black; + padding: 8px; + text-align: left; +} +th { + background-color: #f2f2f2; +} +.result-section { + margin-bottom: 30px; +} \ No newline at end of file