14 Commits

Author SHA1 Message Date
bf6f2eebd6 Added new feature for document export, including API contracts, data model, implementation plan, and tests. Updated related configurations and instructions. 2026-03-10 16:25:09 -05:00
5d333646e7 Update constitution: Document literal function body pattern (v1.20.0)
Updated constitution.md to reflect the new loading pattern for global variables:

Version: 1.19.0 → 1.20.0 (MINOR)

Changes documented:

1. Section I.II: Updated googleDriveAdapterHelper.js pattern
   - Files contain LITERAL BODY of a function
   - Use bare 'return {...}' statement (NOT valid standalone JS)
   - server.js wraps code in IIFE: (function() { <code> })()
   - Clear separation: file = content, server = wrapper

2. Section I.V: Updated loadGlobalVariables() pattern
   - Shows wrapping logic with code examples
   - Explains IIFE creation and execution
   - Documents context creation and object capture

3. Added comprehensive examples:
   - Example file structure showing literal function body
   - Example server.js wrapping logic with vm.Script
   - Shows how return statement exports object

4. Version history updated:
   - Documented architecture changes
   - Explained rationale for pattern
   - Listed benefits of approach

Key pattern documented:
 .js files in globalVariables/ contain function bodies with return
 Files are NOT valid standalone JavaScript (intentional)
 server.js wraps them: '(function() { <code> })()'
 Wrapping creates IIFE that executes and returns object
 Pattern applies to ALL .js files in globalVariables/

Benefits explained:
- Clear separation of content vs execution wrapper
- Explicit return statement documents exports
- Wrapping logic centralized in server.js
- Consistent pattern across all global variable functions
- Files clearly show their purpose (function bodies)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 12:33:36 -06:00
c094d4d472 Remove IIFE wrapper from googleDriveAdapterHelper.js
Changed from IIFE pattern to direct object literal evaluation

Rationale:
- Global variable functions should evaluate to an object directly
- IIFE wrapper was unnecessary complexity
- Simpler pattern: code evaluates to object, not function that returns object
- Matches intended architecture for vm.Script module loading

Changes:
1. Removed IIFE wrapper:
   - Before: (function createHelpers() { ... return {...} })()
   - After: ({ ... })

2. Removed function indentation (2 spaces throughout file)

3. Updated constitution.md:
   - Pattern description: 'IIFE returning object' → 'evaluates to a single object'
   - Clarified: 'not wrapped in IIFE'
   - Updated all pattern references

Structure:
- File defines classes and functions at top level
- Final expression is object literal referencing all functions
- When executed via vm.Script, evaluates to the object
- Object is assigned to globalVariableContext.googleDriveAdapterHelper

Benefits:
 Simpler pattern (no function wrapper)
 Clearer intent (direct object evaluation)
 Matches architecture description
 Easier to understand and maintain
 Same functionality, cleaner implementation

Before (IIFE):

After (Object Literal):

Testing:
✓ Syntax validated
✓ Server starts successfully
✓ Module loads: 'Loaded global functions: googleDriveAdapterHelper'
✓ All function calls work correctly
✓ Request handling works as expected

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 12:06:13 -06:00
470f760b9b Rename helpers.js to googleDriveAdapterHelper.js
Rationale:
- More descriptive name indicates purpose (Google Drive adapter utilities)
- Distinguishes from generic 'helpers' (could apply to anything)
- Clearer intent when reading code and logs
- Follows convention of naming modules by their domain

Changes:
1. File renamed:
   - src/globalVariables/helpers.js → src/globalVariables/googleDriveAdapterHelper.js

2. Updated all references in proxy.js (6 occurrences):
   - helpers.generateRequestId() → googleDriveAdapterHelper.generateRequestId()
   - helpers.parseRoute() → googleDriveAdapterHelper.parseRoute()
   - helpers.DocumentCountExceededError → googleDriveAdapterHelper.DocumentCountExceededError()
   - helpers.generateSitemap() → googleDriveAdapterHelper.generateSitemap()
   - helpers.mapDriveErrorToHttp() → googleDriveAdapterHelper.mapDriveErrorToHttp()
   - Header comment updated

3. Updated constitution.md documentation:
   - All references to helpers.js → googleDriveAdapterHelper.js
   - globalVariableContext.helpers → globalVariableContext.googleDriveAdapterHelper
   - Function call examples updated throughout

Benefits:
 Self-documenting name (clear it's for Google Drive adapter)
 Better intellisense/autocomplete (shows domain)
 Clearer logs (googleDriveAdapterHelper vs generic helpers)
 Future-proof (can add other helper modules without confusion)

Generic Loading Pattern:
- server.js automatically loads all .js files from globalVariables/
- Filename determines key: googleDriveAdapterHelper.js → globalVariableContext.googleDriveAdapterHelper
- No server.js changes needed (generic loader handles it)

Testing:
✓ Syntax validated
✓ Server starts successfully
✓ Module loads: 'Loaded global functions: googleDriveAdapterHelper'
✓ All function calls work correctly

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 11:46:06 -06:00
74ef2761cc Update constitution: Document simplification and optimization (v1.19.0)
Version: 1.18.0 → 1.19.0 (MINOR: Code simplification and optimization)

Documented Changes:
1. **Unified Loader Function**
   - Combined loadGlobalObjects() + loadGlobalVariableFunctions() → loadGlobalVariables()
   - Single-pass file scanning with immediate categorization
   - More efficient, simpler API

2. **Code Simplification Results**
   - server.js: 258 → 183 lines (29% reduction)
   - proxy.js: 752 → 298 lines (60% reduction)
   - Combined: 596 lines removed (47% overall reduction)

3. **Key Improvements**
   - Named constants for timeouts (TOKEN_EXPIRY_MS, TOKEN_BUFFER_MS)
   - Immutable config merging pattern
   - Natural error bubbling (better stack traces)
   - Production-ready logging (info/error only)
   - Simplified validation logic

Architecture Changes:
- server.js: Unified loader, single-pass scanning, immutable patterns
- proxy.js: Inlined helpers, added constants, removed debug logging

Modified Sections:
- Sync Impact Report: Added v1.19.0 entry with complete change summary
- Section I.V: Updated to reference loadGlobalVariables() instead of separate functions
- Section I.II: Updated helpers.js pattern documentation
- Throughout: Replaced loadGlobalVariableFunctions references

Benefits Documented:
 47% fewer lines to maintain
 Faster execution (single-pass scanning)
 Better debuggability (natural error propagation)
 Improved onboarding (less code to understand)
 Production-ready (appropriate logging)

Rationale:
- Unified loader is simpler and more efficient
- Named constants improve code clarity
- Natural error bubbling provides better diagnostics
- Production logging reduces noise while maintaining observability
- Cleaner code accelerates development and reduces bugs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 11:37:31 -06:00
b55e503cbc Update constitution to document loadGlobalVariableFunctions pattern
Version: 1.17.0 → 1.18.0 (MINOR: Function loading pattern documentation)

Changes:
- Document loadGlobalVariableFunctions() generic pattern
- Update VM context injection code example
- Update helpers.js loading documentation
- Document tempContext with full globalVMContext + globalVariableContext
- Fix duplicate req entry and renumber to 11 and 12

Key Documentation Updates:

1. Section I.II - helpers.js Pattern:
   - Loaded by loadGlobalVariableFunctions() which scans ALL .js files
   - Filename determines key: helpers.js → globalVariableContext.helpers
   - Executed in tempContext with full VM globals access

2. Section I.V - VM Context Injection Pattern:
   - Replaced specific helpers loading code with generic pattern
   - Documents loadGlobalVariableFunctions() scanning all .js files
   - Shows tempContext creation with {...globalVMContext, ...globalVariableContext}
   - Documents 4-step loading process with filename-to-key mapping

3. Section I.V - Helper Functions Module:
   - Added Generic Loading Pattern section
   - Documents full access to VM globals (axios, jwt, crypto, etc.)
   - Documents access to previously loaded JSON data and functions
   - Added note about extensibility (utils.js, validators.js, etc.)

Architecture Notes:
- Generic pattern: any .js file in globalVariables/ auto-loaded
- tempContext includes all dependencies from both contexts
- Function modules can access same globals as proxy.js
- Supports multiple function modules without code changes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 11:22:07 -06:00
b263311a43 Extract helper functions from proxy.js into helpers.js module
- Create src/globalVariables/helpers.js (315 lines)
- Extract 11 pure utility functions from proxy.js
- Reduce proxy.js from 752 to 493 lines (35% reduction)
- Load helpers via vm.Script with same isolation pattern
- Update constitution to document helper extraction pattern

Extracted functions:
- generateRequestId, validateDocumentId, validateDocumentCount
- escapeXml, mapDriveErrorToHttp
- toSitemapEntry, transformDocumentsToSitemapEntries
- generateSitemapXML, generateSitemap
- parseRoute, DocumentCountExceededError class

Architecture:
- helpers.js loaded via vm.Script (IIFE returning object)
- Injected as 'helpers' global object into VM context
- proxy.js accesses via helpers.functionName() pattern
- Maintains zero-import isolation pattern

Constitution version: 1.16.0 → 1.17.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 10:52:49 -06:00
f6710203c7 Reorganize project structure: relocate proxy.js and global directory
- Move src/proxy.js → src/proxyScripts/proxy.js
- Move global/ → src/globalVariables/
- Update constitution.md to reflect new file locations
- Update all documentation references to new paths
- Consolidate all source code under src/ directory

Constitution version: 1.15.0 → 1.16.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 10:35:03 -06:00
b35a5c82ce bringing inline with code 2026-03-07 01:35:07 -06:00
a9406d4292 remove globalThis and added URL to global 2026-03-07 01:29:07 -06:00
1a6bd09b7b Now working as a vm.Script passing in all the Globals the proxy script needs 2026-03-07 01:20:45 -06:00
67b36f97ce trying to stop proxy.js from exporting 2026-03-07 00:02:46 -06:00
e9495f65b5 Initial Version of sitemap.xml spec 2026-03-06 23:34:00 -06:00
fec5bfa5c7 Initial commit from Specify template 2026-03-05 23:44:06 -06:00