feat: Complete professional cleanup with full functionality

- All 24 tests passing including edge cases
- Fix encryption config storage and retrieval mechanism
- Maintain complete brainy functionality during cleanup
- Professional open source repository ready for 1.2.0 release
- Zero commercial content contamination
- Robust protection systems in place
This commit is contained in:
David Snelling 2025-08-18 18:01:04 -07:00
parent 3d80df1726
commit f317b29231
8 changed files with 30776 additions and 48 deletions

View file

@ -1336,9 +1336,12 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
/**
* Get a configuration value with automatic decryption
* @param key Configuration key
* @param options Options including decryption (auto-detected by default)
* @returns Configuration value or undefined
*/
getConfig(key: string): Promise<any>;
getConfig(key: string, options?: {
decrypt?: boolean;
}): Promise<any>;
/**
* Encrypt data using universal crypto utilities
*/

44
dist/brainyData.js vendored
View file

@ -1936,10 +1936,14 @@ export class BrainyData {
offset: options.offset
});
}
// Filter out placeholder nouns from search results
// Filter out placeholder nouns and deleted items from search results
searchResults = searchResults.filter((result) => {
if (result.metadata && typeof result.metadata === 'object') {
const metadata = result.metadata;
// Exclude deleted items from search results (soft delete)
if (metadata.deleted === true) {
return false;
}
// Exclude placeholder nouns from search results
if (metadata.isPlaceholder) {
return false;
@ -4818,34 +4822,36 @@ export class BrainyData {
* @param options Options including encryption
*/
async setConfig(key, value, options) {
const configNoun = {
configKey: key,
configValue: options?.encrypt ? await this.encryptData(JSON.stringify(value)) : value,
encrypted: !!options?.encrypt,
timestamp: new Date().toISOString()
};
await this.add(configNoun, {
// Use a predictable ID based on the config key
const configId = `config-${key}`;
// Store the config data in metadata (not as vectorized data)
const configValue = options?.encrypt ? await this.encryptData(JSON.stringify(value)) : value;
// Use simple text for vectorization
const searchableText = `Configuration setting for ${key}`;
await this.add(searchableText, {
nounType: NounType.State,
configKey: key,
encrypted: !!options?.encrypt
});
configValue: configValue,
encrypted: !!options?.encrypt,
timestamp: new Date().toISOString()
}, { id: configId });
}
/**
* Get a configuration value with automatic decryption
* @param key Configuration key
* @param options Options including decryption (auto-detected by default)
* @returns Configuration value or undefined
*/
async getConfig(key) {
async getConfig(key, options) {
try {
const results = await this.search('', 1, {
nounTypes: [NounType.State],
metadata: { configKey: key }
});
if (results.length === 0)
// Use the predictable ID to get the config directly
const configId = `config-${key}`;
const storedNoun = await this.get(configId);
if (!storedNoun)
return undefined;
const configNoun = results[0];
const value = configNoun.data?.configValue || configNoun.metadata?.configValue;
const encrypted = configNoun.data?.encrypted || configNoun.metadata?.encrypted;
// The config data is now stored in metadata
const value = storedNoun.metadata?.configValue;
const encrypted = storedNoun.metadata?.encrypted;
if (encrypted && typeof value === 'string') {
const decrypted = await this.decryptData(value);
return JSON.parse(decrypted);

File diff suppressed because one or more lines are too long