Skip to content

Commit 5ededae

Browse files
author
Bob Strahan
committed
Fix #151 - UI: Document Schema Editor Regex Fields Not Persisting
1 parent 126b9d9 commit 5ededae

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ SPDX-License-Identifier: MIT-0
6363

6464
### Fixed
6565

66+
- **UI: Document Schema Editor Regex Fields Not Persisting** - Fixed issue where Document Name Regex and Page Content Regex fields were not being saved in configuration or restored after page refresh. Fixes #151
6667
- **Document Schema Builder Enum Support** - Fixed enum value handling in schema builder to properly support enumeration constraints for attribute definitions
6768
- **Agentic Extraction Parameter Passing** - Fixed temperature and top_p parameters now correctly passed to agentic extraction service, enabling proper model behavior control
6869
- **Document Schema Builder UI Labels** - Enhanced field labels and formats in document schema builder for improved clarity and user experience

src/ui/src/hooks/useSchemaDesigner.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { useState, useCallback, useEffect } from 'react';
22
import { produce } from 'immer';
3-
import { X_AWS_IDP_DOCUMENT_TYPE, X_AWS_IDP_EXAMPLES } from '../constants/schemaConstants';
3+
import {
4+
X_AWS_IDP_DOCUMENT_TYPE,
5+
X_AWS_IDP_EXAMPLES,
6+
X_AWS_IDP_DOCUMENT_NAME_REGEX,
7+
X_AWS_IDP_PAGE_CONTENT_REGEX,
8+
} from '../constants/schemaConstants';
49

510
const extractInlineObjectsToClasses = (properties, extractedClasses, timestamp) => {
611
const updatedProperties = {};
@@ -129,6 +134,9 @@ const convertJsonSchemaToClasses = (jsonSchema) => {
129134
},
130135
// Preserve examples if they exist in the schema
131136
...(schema[X_AWS_IDP_EXAMPLES] ? { [X_AWS_IDP_EXAMPLES]: schema[X_AWS_IDP_EXAMPLES] } : {}),
137+
// Preserve regex fields if they exist in the schema
138+
...(schema[X_AWS_IDP_DOCUMENT_NAME_REGEX] ? { [X_AWS_IDP_DOCUMENT_NAME_REGEX]: schema[X_AWS_IDP_DOCUMENT_NAME_REGEX] } : {}),
139+
...(schema[X_AWS_IDP_PAGE_CONTENT_REGEX] ? { [X_AWS_IDP_PAGE_CONTENT_REGEX]: schema[X_AWS_IDP_PAGE_CONTENT_REGEX] } : {}),
132140
};
133141
allClasses.push(docTypeClass);
134142

@@ -192,6 +200,9 @@ const convertJsonSchemaToClasses = (jsonSchema) => {
192200
},
193201
// Preserve examples if they exist in the schema
194202
...(jsonSchema[X_AWS_IDP_EXAMPLES] ? { [X_AWS_IDP_EXAMPLES]: jsonSchema[X_AWS_IDP_EXAMPLES] } : {}),
203+
// Preserve regex fields if they exist in the schema
204+
...(jsonSchema[X_AWS_IDP_DOCUMENT_NAME_REGEX] ? { [X_AWS_IDP_DOCUMENT_NAME_REGEX]: jsonSchema[X_AWS_IDP_DOCUMENT_NAME_REGEX] } : {}),
205+
...(jsonSchema[X_AWS_IDP_PAGE_CONTENT_REGEX] ? { [X_AWS_IDP_PAGE_CONTENT_REGEX]: jsonSchema[X_AWS_IDP_PAGE_CONTENT_REGEX] } : {}),
195206
};
196207
classes.push(mainClass);
197208

@@ -619,6 +630,12 @@ export const useSchemaDesigner = (initialSchema = []) => {
619630
...(docTypeClass.attributes.required?.length > 0 ? { required: docTypeClass.attributes.required } : {}),
620631
...(Object.keys(defs).length > 0 ? { $defs: defs } : {}),
621632
...(docTypeClass[X_AWS_IDP_EXAMPLES]?.length > 0 ? { [X_AWS_IDP_EXAMPLES]: docTypeClass[X_AWS_IDP_EXAMPLES] } : {}),
633+
...(docTypeClass[X_AWS_IDP_DOCUMENT_NAME_REGEX]
634+
? { [X_AWS_IDP_DOCUMENT_NAME_REGEX]: docTypeClass[X_AWS_IDP_DOCUMENT_NAME_REGEX] }
635+
: {}),
636+
...(docTypeClass[X_AWS_IDP_PAGE_CONTENT_REGEX]
637+
? { [X_AWS_IDP_PAGE_CONTENT_REGEX]: docTypeClass[X_AWS_IDP_PAGE_CONTENT_REGEX] }
638+
: {}),
622639
};
623640

624641
console.log('Final schema has $defs?', '$defs' in result);

0 commit comments

Comments
 (0)