Major codebase cleanup after .insertr-add functionality overhaul
Consolidates duplicate code and removes technical debt accumulated during rapid development. This cleanup improves maintainability while preserving all functionality. Backend cleanup: - Remove unused legacy function findViableChildrenLegacy() - Consolidate duplicate SQL null string helper functions into shared utils - Unify text extraction functions across utils, engine, and id_generator - Consolidate duplicate attribute getter functions into single implementation Frontend cleanup: - Remove duplicate authentication methods (authenticateWithOAuth vs performOAuthFlow) - Remove unused hasPermission() method from auth.js - Centralize repetitive API endpoint construction in api-client.js - Reduce excessive console logging while preserving important error logs Impact: -144 lines of code, improved maintainability, no functionality changes All tests pass and builds succeed 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -12,11 +12,18 @@ export class ApiClient {
|
||||
this.baseUrl = options.apiEndpoint || defaultEndpoint;
|
||||
this.siteId = options.siteId || this.handleMissingSiteId();
|
||||
|
||||
// Log API configuration in development
|
||||
// Log API configuration in development (keep for debugging)
|
||||
if (isDevelopment && !options.apiEndpoint) {
|
||||
console.log(`🔌 API Client: Using development server at ${this.baseUrl}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collections API URL (helper to avoid repetition)
|
||||
*/
|
||||
getCollectionsUrl() {
|
||||
return this.baseUrl.replace('/api/content', '/api/collections');
|
||||
}
|
||||
|
||||
async getContent(contentId) {
|
||||
try {
|
||||
@@ -48,7 +55,6 @@ export class ApiClient {
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
console.log(`✅ Content created: ${result.id}`);
|
||||
return result;
|
||||
} else {
|
||||
console.warn(`⚠️ Create failed (${response.status}): server will generate ID`);
|
||||
@@ -82,7 +88,6 @@ export class ApiClient {
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
console.log(`✅ Content updated: ${contentId}`);
|
||||
return result;
|
||||
} else {
|
||||
console.warn(`⚠️ Update failed (${response.status}): ${contentId}`);
|
||||
@@ -154,7 +159,7 @@ export class ApiClient {
|
||||
*/
|
||||
async createCollectionItem(collectionId, templateId = 1, htmlContent = '') {
|
||||
try {
|
||||
const collectionsUrl = this.baseUrl.replace('/api/content', '/api/collections');
|
||||
const collectionsUrl = this.getCollectionsUrl();
|
||||
const payload = {
|
||||
site_id: this.siteId,
|
||||
template_id: templateId,
|
||||
@@ -172,7 +177,6 @@ export class ApiClient {
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
console.log(`✅ Collection item created: ${result.item_id}`);
|
||||
return result;
|
||||
} else {
|
||||
const errorText = await response.text();
|
||||
@@ -193,7 +197,7 @@ export class ApiClient {
|
||||
*/
|
||||
async deleteCollectionItem(collectionId, itemId) {
|
||||
try {
|
||||
const collectionsUrl = this.baseUrl.replace('/api/content', '/api/collections');
|
||||
const collectionsUrl = this.getCollectionsUrl();
|
||||
|
||||
const response = await fetch(`${collectionsUrl}/${collectionId}/items/${itemId}?site_id=${this.siteId}`, {
|
||||
method: 'DELETE',
|
||||
@@ -203,7 +207,6 @@ export class ApiClient {
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
console.log(`✅ Collection item deleted: ${itemId}`);
|
||||
return true;
|
||||
} else {
|
||||
const errorText = await response.text();
|
||||
@@ -223,7 +226,7 @@ export class ApiClient {
|
||||
*/
|
||||
async getCollectionItems(collectionId) {
|
||||
try {
|
||||
const collectionsUrl = this.baseUrl.replace('/api/content', '/api/collections');
|
||||
const collectionsUrl = this.getCollectionsUrl();
|
||||
const response = await fetch(`${collectionsUrl}/${collectionId}/items?site_id=${this.siteId}`);
|
||||
|
||||
if (response.ok) {
|
||||
@@ -248,7 +251,7 @@ export class ApiClient {
|
||||
*/
|
||||
async updateCollectionItemPosition(collectionId, itemId, newPosition) {
|
||||
try {
|
||||
const collectionsUrl = this.baseUrl.replace('/api/content', '/api/collections');
|
||||
const collectionsUrl = this.getCollectionsUrl();
|
||||
const payload = {
|
||||
site_id: this.siteId,
|
||||
position: newPosition
|
||||
@@ -264,7 +267,6 @@ export class ApiClient {
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
console.log(`✅ Collection item position updated: ${itemId} → position ${newPosition}`);
|
||||
return true;
|
||||
} else {
|
||||
const errorText = await response.text();
|
||||
|
||||
Reference in New Issue
Block a user