001-drive-proxy-adapter #1
@@ -204,9 +204,9 @@ Follow-up TODOs:
|
|||||||
|
|
||||||
**Helper Functions Pattern**: Pure utility functions (XML escaping, validation, formatting, routing) MAY be extracted to `src/globalVariables/googleDriveAdapterHelper.js` to improve readability and maintainability. The helpers module:
|
**Helper Functions Pattern**: Pure utility functions (XML escaping, validation, formatting, routing) MAY be extracted to `src/globalVariables/googleDriveAdapterHelper.js` to improve readability and maintainability. The helpers module:
|
||||||
- MUST be loaded via `vm.Script` (same isolation as proxy.js)
|
- MUST be loaded via `vm.Script` (same isolation as proxy.js)
|
||||||
- MUST return a single object with all helper functions
|
- MUST evaluate to a single JavaScript object with all helper functions
|
||||||
- MUST have ZERO imports/exports
|
- MUST have ZERO imports/exports
|
||||||
- Is injected as `helpers` global object into VM context
|
- Is injected as `googleDriveAdapterHelper` global object into VM context
|
||||||
- Contains ONLY pure utilities, NO business logic or state
|
- Contains ONLY pure utilities, NO business logic or state
|
||||||
|
|
||||||
### I. Zero External Imports or Exports from `src/proxyScripts/proxy.js` (NON-NEGOTIABLE)
|
### I. Zero External Imports or Exports from `src/proxyScripts/proxy.js` (NON-NEGOTIABLE)
|
||||||
@@ -291,11 +291,11 @@ config/
|
|||||||
|
|
||||||
**googleDriveAdapterHelper.js Pattern**:
|
**googleDriveAdapterHelper.js Pattern**:
|
||||||
- MUST be loaded using `vm.Script` (same isolation as proxy.js)
|
- MUST be loaded using `vm.Script` (same isolation as proxy.js)
|
||||||
- MUST return single object with all helper functions via IIFE
|
- MUST evaluate to a single JavaScript object (not wrapped in IIFE)
|
||||||
- MUST have ZERO imports/exports (pure vm.Script execution)
|
- MUST have ZERO imports/exports (pure vm.Script execution)
|
||||||
- Loaded by `loadGlobalVariables()` which scans for both JSON and JS files
|
- Loaded by `loadGlobalVariables()` which scans for both JSON and JS files
|
||||||
- Filename determines global key: `googleDriveAdapterHelper.js` → `globalVariableContext.helpers`
|
- Filename determines global key: `googleDriveAdapterHelper.js` → `globalVariableContext.googleDriveAdapterHelper`
|
||||||
- Injected as `helpers` global object into VM context
|
- Injected as `googleDriveAdapterHelper` global object into VM context
|
||||||
- Contains ONLY pure utilities: validators, formatters, XML, error mappers
|
- Contains ONLY pure utilities: validators, formatters, XML, error mappers
|
||||||
- MUST NOT contain: authentication, API calls, state, business decisions
|
- MUST NOT contain: authentication, API calls, state, business decisions
|
||||||
- Executed in context with full access to globalVMContext and globalVariableContext
|
- Executed in context with full access to globalVMContext and globalVariableContext
|
||||||
@@ -441,7 +441,6 @@ script.runInContext(context);
|
|||||||
10. **googleDriveAdapterHelper** - Pure utility functions object (OPTIONAL)
|
10. **googleDriveAdapterHelper** - Pure utility functions object (OPTIONAL)
|
||||||
- Purpose: Extracted helper functions for code organization
|
- Purpose: Extracted helper functions for code organization
|
||||||
- Source: `src/globalVariables/googleDriveAdapterHelper.js` loaded via `vm.Script`
|
- Source: `src/globalVariables/googleDriveAdapterHelper.js` loaded via `vm.Script`
|
||||||
- Pattern: IIFE returning object with all helper functions
|
|
||||||
- Loading: server.js loads via `loadGlobalVariables()` at startup
|
- Loading: server.js loads via `loadGlobalVariables()` at startup
|
||||||
- Generic Loading Pattern:
|
- Generic Loading Pattern:
|
||||||
- All .js files in globalVariables/ are loaded automatically
|
- All .js files in globalVariables/ are loaded automatically
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
* @returns {Object} Helpers object with all utility functions
|
* @returns {Object} Helpers object with all utility functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Wrap in IIFE that returns helpers object
|
|
||||||
(function createHelpers() {
|
|
||||||
/**
|
/**
|
||||||
* Custom error for document count exceeding limit
|
* Custom error for document count exceeding limit
|
||||||
*/
|
*/
|
||||||
@@ -288,7 +286,7 @@
|
|||||||
// Return helpers object with all functions
|
// Return helpers object with all functions
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
return {
|
({
|
||||||
// Error classes
|
// Error classes
|
||||||
DocumentCountExceededError,
|
DocumentCountExceededError,
|
||||||
|
|
||||||
@@ -311,5 +309,4 @@
|
|||||||
|
|
||||||
// Routing
|
// Routing
|
||||||
parseRoute,
|
parseRoute,
|
||||||
};
|
});
|
||||||
})();
|
|
||||||
|
|||||||
Reference in New Issue
Block a user