@optimizely/ocp-local-env 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -0
- package/dist/package.json +104 -0
- package/dist/public/bundle.da978bb5437cd82e6d37.js +3 -0
- package/dist/public/bundle.da978bb5437cd82e6d37.js.LICENSE.txt +49 -0
- package/dist/public/bundle.da978bb5437cd82e6d37.js.map +1 -0
- package/dist/public/index.html +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +88 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/executor/FunctionExecutor.d.ts +56 -0
- package/dist/src/executor/FunctionExecutor.js +175 -0
- package/dist/src/executor/FunctionExecutor.js.map +1 -0
- package/dist/src/executor/JobExecutor.d.ts +60 -0
- package/dist/src/executor/JobExecutor.js +203 -0
- package/dist/src/executor/JobExecutor.js.map +1 -0
- package/dist/src/executor/LifecycleExecutor.d.ts +45 -0
- package/dist/src/executor/LifecycleExecutor.js +153 -0
- package/dist/src/executor/LifecycleExecutor.js.map +1 -0
- package/dist/src/executor/watcher.d.ts +63 -0
- package/dist/src/executor/watcher.js +213 -0
- package/dist/src/executor/watcher.js.map +1 -0
- package/dist/src/functions/hello.d.ts +4 -0
- package/dist/src/functions/hello.js +8 -0
- package/dist/src/functions/hello.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/jobs/dailyJob.d.ts +4 -0
- package/dist/src/jobs/dailyJob.js +8 -0
- package/dist/src/jobs/dailyJob.js.map +1 -0
- package/dist/src/local_engine/LocalNotifier.d.ts +10 -0
- package/dist/src/local_engine/LocalNotifier.js +26 -0
- package/dist/src/local_engine/LocalNotifier.js.map +1 -0
- package/dist/src/local_engine/local-engine-child-base.d.ts +79 -0
- package/dist/src/local_engine/local-engine-child-base.js +304 -0
- package/dist/src/local_engine/local-engine-child-base.js.map +1 -0
- package/dist/src/local_engine/local-engine-client.d.ts +80 -0
- package/dist/src/local_engine/local-engine-client.js +333 -0
- package/dist/src/local_engine/local-engine-client.js.map +1 -0
- package/dist/src/local_engine/local-engine-types.d.ts +132 -0
- package/dist/src/local_engine/local-engine-types.js +6 -0
- package/dist/src/local_engine/local-engine-types.js.map +1 -0
- package/dist/src/local_engine/local-engine-unified.d.ts +40 -0
- package/dist/src/local_engine/local-engine-unified.js +406 -0
- package/dist/src/local_engine/local-engine-unified.js.map +1 -0
- package/dist/src/local_engine/local-engine-utils.d.ts +70 -0
- package/dist/src/local_engine/local-engine-utils.js +192 -0
- package/dist/src/local_engine/local-engine-utils.js.map +1 -0
- package/dist/src/local_engine/localSDKConfig.d.ts +30 -0
- package/dist/src/local_engine/localSDKConfig.js +392 -0
- package/dist/src/local_engine/localSDKConfig.js.map +1 -0
- package/dist/src/local_engine/storage/LocalConfigStore.d.ts +56 -0
- package/dist/src/local_engine/storage/LocalConfigStore.js +129 -0
- package/dist/src/local_engine/storage/LocalConfigStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalJobStore.d.ts +110 -0
- package/dist/src/local_engine/storage/LocalJobStore.js +239 -0
- package/dist/src/local_engine/storage/LocalJobStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalKVStore.d.ts +105 -0
- package/dist/src/local_engine/storage/LocalKVStore.js +1002 -0
- package/dist/src/local_engine/storage/LocalKVStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.d.ts +27 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.js +125 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.d.ts +114 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.js +319 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.d.ts +161 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.js +417 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.js.map +1 -0
- package/dist/src/local_engine/storage/NumberSet.d.ts +21 -0
- package/dist/src/local_engine/storage/NumberSet.js +32 -0
- package/dist/src/local_engine/storage/NumberSet.js.map +1 -0
- package/dist/src/local_engine/storage/StringSet.d.ts +21 -0
- package/dist/src/local_engine/storage/StringSet.js +32 -0
- package/dist/src/local_engine/storage/StringSet.js.map +1 -0
- package/dist/src/local_engine/types.d.ts +52 -0
- package/dist/src/local_engine/types.js +6 -0
- package/dist/src/local_engine/types.js.map +1 -0
- package/dist/src/local_engine/utils.d.ts +31 -0
- package/dist/src/local_engine/utils.js +126 -0
- package/dist/src/local_engine/utils.js.map +1 -0
- package/dist/src/logging/LogManager.d.ts +89 -0
- package/dist/src/logging/LogManager.js +237 -0
- package/dist/src/logging/LogManager.js.map +1 -0
- package/dist/src/server/api/functions.d.ts +7 -0
- package/dist/src/server/api/functions.js +80 -0
- package/dist/src/server/api/functions.js.map +1 -0
- package/dist/src/server/api/jobs.d.ts +8 -0
- package/dist/src/server/api/jobs.js +242 -0
- package/dist/src/server/api/jobs.js.map +1 -0
- package/dist/src/server/api/lifecycle.d.ts +6 -0
- package/dist/src/server/api/lifecycle.js +73 -0
- package/dist/src/server/api/lifecycle.js.map +1 -0
- package/dist/src/server/api/settings.d.ts +6 -0
- package/dist/src/server/api/settings.js +117 -0
- package/dist/src/server/api/settings.js.map +1 -0
- package/dist/src/server/api/stores.d.ts +2 -0
- package/dist/src/server/api/stores.js +341 -0
- package/dist/src/server/api/stores.js.map +1 -0
- package/dist/src/server/api/v1.d.ts +10 -0
- package/dist/src/server/api/v1.js +711 -0
- package/dist/src/server/api/v1.js.map +1 -0
- package/dist/src/server/api.d.ts +8 -0
- package/dist/src/server/api.js +154 -0
- package/dist/src/server/api.js.map +1 -0
- package/dist/src/server/app-discovery.d.ts +5 -0
- package/dist/src/server/app-discovery.js +81 -0
- package/dist/src/server/app-discovery.js.map +1 -0
- package/dist/src/server/config.d.ts +21 -0
- package/dist/src/server/config.js +100 -0
- package/dist/src/server/config.js.map +1 -0
- package/dist/src/server/websocket.d.ts +0 -0
- package/dist/src/server/websocket.js +2 -0
- package/dist/src/server/websocket.js.map +1 -0
- package/dist/src/server.d.ts +2 -0
- package/dist/src/server.js +546 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/types/app.d.ts +155 -0
- package/dist/src/types/app.js +24 -0
- package/dist/src/types/app.js.map +1 -0
- package/dist/src/types/kvstore.d.ts +320 -0
- package/dist/src/types/kvstore.js +5 -0
- package/dist/src/types/kvstore.js.map +1 -0
- package/dist/src/ui/components/App.d.ts +6 -0
- package/dist/src/ui/components/App.js +255 -0
- package/dist/src/ui/components/App.js.map +1 -0
- package/dist/src/ui/components/FunctionsView.d.ts +6 -0
- package/dist/src/ui/components/FunctionsView.js +217 -0
- package/dist/src/ui/components/FunctionsView.js.map +1 -0
- package/dist/src/ui/components/JobsView.d.ts +6 -0
- package/dist/src/ui/components/JobsView.js +257 -0
- package/dist/src/ui/components/JobsView.js.map +1 -0
- package/dist/src/ui/components/KVStoreViewer.d.ts +11 -0
- package/dist/src/ui/components/KVStoreViewer.js +168 -0
- package/dist/src/ui/components/KVStoreViewer.js.map +1 -0
- package/dist/src/ui/components/NotificationViewer.d.ts +16 -0
- package/dist/src/ui/components/NotificationViewer.js +69 -0
- package/dist/src/ui/components/NotificationViewer.js.map +1 -0
- package/dist/src/ui/components/SecretsStoreViewer.d.ts +11 -0
- package/dist/src/ui/components/SecretsStoreViewer.js +179 -0
- package/dist/src/ui/components/SecretsStoreViewer.js.map +1 -0
- package/dist/src/ui/components/SettingsStoreViewer.d.ts +24 -0
- package/dist/src/ui/components/SettingsStoreViewer.js +132 -0
- package/dist/src/ui/components/SettingsStoreViewer.js.map +1 -0
- package/dist/src/ui/components/StoreViewer.d.ts +16 -0
- package/dist/src/ui/components/StoreViewer.js +86 -0
- package/dist/src/ui/components/StoreViewer.js.map +1 -0
- package/dist/src/ui/components/TabbedConsole.d.ts +15 -0
- package/dist/src/ui/components/TabbedConsole.js +93 -0
- package/dist/src/ui/components/TabbedConsole.js.map +1 -0
- package/dist/src/ui/components/common/DataTree.d.ts +15 -0
- package/dist/src/ui/components/common/DataTree.js +95 -0
- package/dist/src/ui/components/common/DataTree.js.map +1 -0
- package/dist/src/ui/components/common/EyeIcon.d.ts +11 -0
- package/dist/src/ui/components/common/EyeIcon.js +11 -0
- package/dist/src/ui/components/common/EyeIcon.js.map +1 -0
- package/dist/src/ui/index.d.ts +1 -0
- package/dist/src/ui/index.js +20 -0
- package/dist/src/ui/index.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Local Engine Unified
|
|
5
|
+
*
|
|
6
|
+
* This script runs in the app's Node.js process context and executes both OCP functions
|
|
7
|
+
* and lifecycle methods using IPC communication with the parent process.
|
|
8
|
+
* This is a single, persistent process that handles all app execution requests.
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.LocalEngineUnified = void 0;
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const local_engine_child_base_1 = require("./local-engine-child-base");
|
|
18
|
+
const utils_1 = require("./utils");
|
|
19
|
+
class LocalEngineUnified extends local_engine_child_base_1.LocalEngineChildBase {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.isInitialized = false;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the wrapper with app configuration
|
|
26
|
+
* This happens once when the process starts
|
|
27
|
+
*/
|
|
28
|
+
async initialize(appConfig, appDir) {
|
|
29
|
+
if (this.isInitialized) {
|
|
30
|
+
this.sendLog('info', 'Wrapper already initialized, skipping initialization');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.sendLog('info', `Initializing unified wrapper for app: ${appConfig.manifest.meta?.app_id || 'unknown'}`);
|
|
34
|
+
try {
|
|
35
|
+
// Load the SDK from app's node_modules
|
|
36
|
+
this.sdkComponents = (0, utils_1.loadAppSDK)(appDir);
|
|
37
|
+
this.sendLog('info', 'SDK loaded successfully');
|
|
38
|
+
// Import local engine components using dynamic require
|
|
39
|
+
const localEngineDir = __dirname;
|
|
40
|
+
const storageDir = path_1.default.join(__dirname, 'storage');
|
|
41
|
+
const localSDKConfig = require(path_1.default.join(localEngineDir, 'localSDKConfig'));
|
|
42
|
+
this.configureLocalSDKs = localSDKConfig.configureLocalSDKs;
|
|
43
|
+
this.cleanUpLocalSDKs = localSDKConfig.cleanUpLocalSDKs;
|
|
44
|
+
this.LocalSettingsStore = require(path_1.default.join(storageDir, 'LocalSettingsStore')).LocalSettingsStore;
|
|
45
|
+
this.LocalConfigStore = require(path_1.default.join(storageDir, 'LocalConfigStore')).LocalConfigStore;
|
|
46
|
+
this.sendLog('info', 'Local engine components loaded');
|
|
47
|
+
// Configure SDKs for the app
|
|
48
|
+
const settingsStore = this.LocalSettingsStore.getInstance(appDir);
|
|
49
|
+
const configStore = new this.LocalConfigStore(appDir);
|
|
50
|
+
this.sendLog('info', 'Configuring SDKs for local testing...');
|
|
51
|
+
this.configureLocalSDKs(appConfig, settingsStore, appDir, 1, configStore);
|
|
52
|
+
this.isInitialized = true;
|
|
53
|
+
this.sendLog('info', 'Unified wrapper initialized successfully - ready to handle function and lifecycle requests');
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
this.sendLog('error', `Initialization failed: ${error}`);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Execute a function with the given request
|
|
62
|
+
*/
|
|
63
|
+
async executeFunction(request) {
|
|
64
|
+
if (!this.appConfig || !this.appDir) {
|
|
65
|
+
throw new Error('Wrapper not properly initialized');
|
|
66
|
+
}
|
|
67
|
+
if (!this.isInitialized) {
|
|
68
|
+
throw new Error('SDK not initialized');
|
|
69
|
+
}
|
|
70
|
+
this.sendLog('info', `Executing function: ${request.functionId}`, this.currentRequestId);
|
|
71
|
+
this.sendProgress(this.currentRequestId, 'Finding function file', 20);
|
|
72
|
+
// Find the built function file
|
|
73
|
+
const functionPath = (0, utils_1.findFunctionFile)(this.appDir, request.functionId, this.appConfig.manifest);
|
|
74
|
+
this.sendLog('info', `Using function file: ${functionPath}`, this.currentRequestId);
|
|
75
|
+
this.sendProgress(this.currentRequestId, 'Loading function module', 40);
|
|
76
|
+
// Load the function module
|
|
77
|
+
const FunctionModule = require(functionPath);
|
|
78
|
+
const FunctionClass = (0, utils_1.findFunctionClass)(FunctionModule);
|
|
79
|
+
this.sendLog('info', 'Function class found, creating request object...', this.currentRequestId);
|
|
80
|
+
this.sendProgress(this.currentRequestId, 'Creating request object', 60);
|
|
81
|
+
// Convert headers array to the format expected by InternalRequest
|
|
82
|
+
const headers = request.headers || [];
|
|
83
|
+
// Convert body to Uint8Array if present
|
|
84
|
+
let bodyArray = null;
|
|
85
|
+
if (request.body !== null && request.body !== undefined) {
|
|
86
|
+
const bodyString = typeof request.body === 'string' ?
|
|
87
|
+
request.body : JSON.stringify(request.body);
|
|
88
|
+
bodyArray = new Uint8Array(Buffer.from(bodyString, 'utf8'));
|
|
89
|
+
}
|
|
90
|
+
const internalRequest = new this.sdkComponents.App.InternalRequest(request.method, request.fullpath, request.path, request.params || {}, headers, bodyArray);
|
|
91
|
+
this.sendLog('debug', `Created InternalRequest - method: ${request.method}, path: ${request.path}`, this.currentRequestId);
|
|
92
|
+
// Create function instance and call perform
|
|
93
|
+
const functionInstance = new FunctionClass(internalRequest);
|
|
94
|
+
if (typeof functionInstance.perform !== 'function') {
|
|
95
|
+
throw new Error('Function class does not implement perform method');
|
|
96
|
+
}
|
|
97
|
+
this.sendLog('info', 'Executing function perform method...', this.currentRequestId);
|
|
98
|
+
this.sendProgress(this.currentRequestId, 'Executing function', 80);
|
|
99
|
+
// Call the function's perform method
|
|
100
|
+
const response = await functionInstance.perform();
|
|
101
|
+
this.sendLog('info', `Function execution completed - status: ${response.status}`, this.currentRequestId);
|
|
102
|
+
this.sendProgress(this.currentRequestId, 'Function execution completed', 100);
|
|
103
|
+
// Convert response to serializable format
|
|
104
|
+
const result = {
|
|
105
|
+
success: true,
|
|
106
|
+
status: response.status || 200,
|
|
107
|
+
headers: response.headers ? response.headers.toArray() : [],
|
|
108
|
+
body: response.bodyAsU8Array ? Array.from(response.bodyAsU8Array) : null
|
|
109
|
+
};
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Execute a lifecycle method with the given request
|
|
114
|
+
*/
|
|
115
|
+
async executeLifecycle(request) {
|
|
116
|
+
if (!this.appConfig || !this.appDir) {
|
|
117
|
+
throw new Error('Wrapper not properly initialized');
|
|
118
|
+
}
|
|
119
|
+
if (!this.isInitialized) {
|
|
120
|
+
throw new Error('SDK not initialized');
|
|
121
|
+
}
|
|
122
|
+
this.sendLog('info', `Executing lifecycle method: ${request.method}`, this.currentRequestId);
|
|
123
|
+
this.sendProgress(this.currentRequestId, 'Checking lifecycle file', 20);
|
|
124
|
+
// Check if built file exists
|
|
125
|
+
if (!fs_1.default.existsSync(request.scriptPath)) {
|
|
126
|
+
throw new Error(`Lifecycle file not built or not found at ${request.scriptPath}`);
|
|
127
|
+
}
|
|
128
|
+
this.sendLog('info', `Using lifecycle file: ${request.scriptPath}`, this.currentRequestId);
|
|
129
|
+
this.sendProgress(this.currentRequestId, 'Loading lifecycle module', 40);
|
|
130
|
+
// Load the lifecycle module
|
|
131
|
+
const LifecycleModule = require(request.scriptPath);
|
|
132
|
+
const LifecycleClass = (0, utils_1.findLifecycleClass)(LifecycleModule);
|
|
133
|
+
// Create instance and call the method
|
|
134
|
+
const lifecycle = new LifecycleClass();
|
|
135
|
+
if (typeof lifecycle[request.method] !== 'function') {
|
|
136
|
+
throw new Error(`Method ${request.method} not found on Lifecycle class`);
|
|
137
|
+
}
|
|
138
|
+
this.sendLog('info', `Executing ${request.method} with params: ${JSON.stringify(request.params)}`, this.currentRequestId);
|
|
139
|
+
this.sendProgress(this.currentRequestId, 'Executing lifecycle method', 60);
|
|
140
|
+
// Call the lifecycle method with appropriate parameters
|
|
141
|
+
let result;
|
|
142
|
+
if (request.method === 'onUpgrade') {
|
|
143
|
+
result = await lifecycle[request.method](request.params?.fromVersion || '0.0.0');
|
|
144
|
+
}
|
|
145
|
+
else if (request.method === 'onSettingsForm') {
|
|
146
|
+
const params = request.params || {};
|
|
147
|
+
result = await lifecycle[request.method](params.page, params.action, params.formData);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
result = await lifecycle[request.method]();
|
|
151
|
+
}
|
|
152
|
+
this.sendLog('info', `Lifecycle method result: ${JSON.stringify(result)}`, this.currentRequestId);
|
|
153
|
+
this.sendProgress(this.currentRequestId, 'Processing result', 80);
|
|
154
|
+
// Handle different lifecycle method return types
|
|
155
|
+
let processedResult;
|
|
156
|
+
if (request.method === 'onSettingsForm') {
|
|
157
|
+
// The result should be a LifecycleSettingsResult with getResponse method
|
|
158
|
+
let settingsResponse = {};
|
|
159
|
+
if (result && typeof result.getResponse === 'function') {
|
|
160
|
+
this.sendLog('debug', 'Getting response from LifecycleSettingsResult', this.currentRequestId);
|
|
161
|
+
const params = request.params || {};
|
|
162
|
+
settingsResponse = result.getResponse(params.page);
|
|
163
|
+
this.sendLog('debug', `Settings response: ${JSON.stringify(settingsResponse)}`, this.currentRequestId);
|
|
164
|
+
}
|
|
165
|
+
else if (result) {
|
|
166
|
+
this.sendLog('debug', 'Using result as fallback', this.currentRequestId);
|
|
167
|
+
// Fallback - use result as is
|
|
168
|
+
settingsResponse = result;
|
|
169
|
+
}
|
|
170
|
+
// Mock the storage.settings.getAllSections() call since we don't have the full SDK context
|
|
171
|
+
// In real implementation, this would fetch from the app's settings store
|
|
172
|
+
const mockFormData = {}; // This will be populated by the REST endpoint
|
|
173
|
+
processedResult = {
|
|
174
|
+
result: settingsResponse,
|
|
175
|
+
data: mockFormData
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
else if (request.method === 'onInstall' || request.method === 'onUninstall' || request.method === 'onUpgrade') {
|
|
179
|
+
// These methods return LifecycleResult with success property
|
|
180
|
+
if (result && typeof result === 'object' && 'success' in result) {
|
|
181
|
+
processedResult = result;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// If the result doesn't have success property, assume success if no error was thrown
|
|
185
|
+
this.sendLog('warn', `Lifecycle method ${request.method} did not return a proper LifecycleResult object. Assuming success.`, this.currentRequestId);
|
|
186
|
+
processedResult = {
|
|
187
|
+
success: true,
|
|
188
|
+
message: result?.message || 'Operation completed without explicit success status'
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else if (request.method === 'canUninstall') {
|
|
193
|
+
// canUninstall returns CanUninstallResult with uninstallable property
|
|
194
|
+
if (result && typeof result === 'object' && 'uninstallable' in result) {
|
|
195
|
+
processedResult = result;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// If the result doesn't have uninstallable property, this is an error
|
|
199
|
+
throw new Error(`Lifecycle method canUninstall did not return a proper CanUninstallResult object with uninstallable property. Result: ${JSON.stringify(result)}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// Default fallback for other methods
|
|
204
|
+
processedResult = result;
|
|
205
|
+
}
|
|
206
|
+
this.sendProgress(this.currentRequestId, 'Lifecycle execution completed', 100);
|
|
207
|
+
return {
|
|
208
|
+
success: request.method === 'onSettingsForm' ? true : (processedResult?.success !== false),
|
|
209
|
+
result: processedResult
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Execute a job with the given request
|
|
214
|
+
*/
|
|
215
|
+
async executeJob(request) {
|
|
216
|
+
if (!this.appConfig || !this.appDir) {
|
|
217
|
+
throw new Error('Local engine not properly initialized');
|
|
218
|
+
}
|
|
219
|
+
if (!this.isInitialized) {
|
|
220
|
+
throw new Error('SDK not initialized');
|
|
221
|
+
}
|
|
222
|
+
this.sendLog('info', `Executing job: ${request.jobId}`, this.currentRequestId);
|
|
223
|
+
this.sendProgress(this.currentRequestId, 'Finding job file', 20);
|
|
224
|
+
// Find job definition in manifest
|
|
225
|
+
const manifest = this.appConfig.manifest;
|
|
226
|
+
let jobDef = null;
|
|
227
|
+
let isSourceJob = false;
|
|
228
|
+
// Check regular jobs
|
|
229
|
+
if (manifest.jobs && manifest.jobs[request.jobId]) {
|
|
230
|
+
jobDef = manifest.jobs[request.jobId];
|
|
231
|
+
isSourceJob = false;
|
|
232
|
+
}
|
|
233
|
+
// Check source jobs (nested under sources)
|
|
234
|
+
else if (manifest.sources) {
|
|
235
|
+
for (const [sourceId, source] of Object.entries(manifest.sources)) {
|
|
236
|
+
const sourceAny = source;
|
|
237
|
+
if (sourceAny.jobs) {
|
|
238
|
+
const compositeJobId = `${sourceId}_${Object.keys(sourceAny.jobs)[0]}`;
|
|
239
|
+
if (compositeJobId === request.jobId || Object.keys(sourceAny.jobs).includes(request.jobId)) {
|
|
240
|
+
const actualJobId = request.jobId.includes('_') ? request.jobId.split('_')[1] : request.jobId;
|
|
241
|
+
jobDef = sourceAny.jobs[actualJobId];
|
|
242
|
+
isSourceJob = true;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (!jobDef) {
|
|
249
|
+
throw new Error(`Job not found in manifest: ${request.jobId}`);
|
|
250
|
+
}
|
|
251
|
+
// Find the built job file
|
|
252
|
+
const jobPath = path_1.default.join(this.appDir, 'dist', 'jobs', `${jobDef.entry_point}.js`);
|
|
253
|
+
if (!fs_1.default.existsSync(jobPath)) {
|
|
254
|
+
throw new Error(`Job file not built or not found: dist/jobs/${jobDef.entry_point}.js`);
|
|
255
|
+
}
|
|
256
|
+
this.sendLog('info', `Using job file: ${jobPath}`, this.currentRequestId);
|
|
257
|
+
this.sendProgress(this.currentRequestId, 'Loading job module', 40);
|
|
258
|
+
// Import job module
|
|
259
|
+
const JobModule = require(jobPath);
|
|
260
|
+
// Find job class (look for default export or named export matching entry point)
|
|
261
|
+
let JobClass = JobModule.default || JobModule[jobDef.entry_point] || JobModule;
|
|
262
|
+
if (typeof JobClass !== 'function') {
|
|
263
|
+
// Look for any class in the module
|
|
264
|
+
const exports = Object.keys(JobModule);
|
|
265
|
+
for (const key of exports) {
|
|
266
|
+
if (typeof JobModule[key] === 'function' && JobModule[key].prototype) {
|
|
267
|
+
JobClass = JobModule[key];
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (typeof JobClass !== 'function') {
|
|
273
|
+
throw new Error(`No job class found in ${jobPath}`);
|
|
274
|
+
}
|
|
275
|
+
this.sendLog('info', 'Job class found, creating invocation...', this.currentRequestId);
|
|
276
|
+
this.sendProgress(this.currentRequestId, 'Creating job invocation', 60);
|
|
277
|
+
// Create job invocation
|
|
278
|
+
const invocation = {
|
|
279
|
+
jobId: `${request.jobId}_${Date.now()}`,
|
|
280
|
+
scheduledAt: new Date(),
|
|
281
|
+
parameters: request.parameters || {}
|
|
282
|
+
};
|
|
283
|
+
// Add dataSyncId for source jobs
|
|
284
|
+
if (isSourceJob && request.dataSyncId) {
|
|
285
|
+
invocation.dataSyncId = request.dataSyncId;
|
|
286
|
+
}
|
|
287
|
+
this.sendLog('info', 'Creating job instance...', this.currentRequestId);
|
|
288
|
+
// Create job instance
|
|
289
|
+
let jobInstance;
|
|
290
|
+
if (isSourceJob && request.dataSyncId) {
|
|
291
|
+
// Source job requires source parameter
|
|
292
|
+
const mockSource = { id: request.sourceKey || 'local-source' };
|
|
293
|
+
jobInstance = new JobClass(invocation, mockSource);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
jobInstance = new JobClass(invocation);
|
|
297
|
+
}
|
|
298
|
+
// Validate job instance has required methods
|
|
299
|
+
if (typeof jobInstance.prepare !== 'function') {
|
|
300
|
+
throw new Error('Job class does not implement prepare method');
|
|
301
|
+
}
|
|
302
|
+
if (typeof jobInstance.perform !== 'function') {
|
|
303
|
+
throw new Error('Job class does not implement perform method');
|
|
304
|
+
}
|
|
305
|
+
this.sendLog('info', 'Executing job prepare method...', this.currentRequestId);
|
|
306
|
+
this.sendProgress(this.currentRequestId, 'Preparing job', 70);
|
|
307
|
+
// Import LocalJobStore to track state
|
|
308
|
+
const { LocalJobStore } = require('./storage/LocalJobStore');
|
|
309
|
+
const jobStore = LocalJobStore.getInstance(request.appDir);
|
|
310
|
+
const { createHash } = require('crypto');
|
|
311
|
+
let status;
|
|
312
|
+
let statusHash;
|
|
313
|
+
try {
|
|
314
|
+
// Execute prepare phase
|
|
315
|
+
this.sendLog('info', 'Executing job prepare method...', this.currentRequestId);
|
|
316
|
+
status = await jobInstance.prepare(request.parameters || {});
|
|
317
|
+
statusHash = createHash('sha256').update(JSON.stringify(status)).digest('hex');
|
|
318
|
+
// Save initial state from prepare
|
|
319
|
+
jobStore.saveState(request.executionId, status, status.complete || false, statusHash, 'prepare');
|
|
320
|
+
this.sendLog('info', 'Job prepared successfully', this.currentRequestId);
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
this.sendLog('error', `Job prepare failed: ${error.message}`, this.currentRequestId);
|
|
324
|
+
// Mark job as failed in store
|
|
325
|
+
const { LocalJobStore, JobExecutionStatus } = require('./storage/LocalJobStore');
|
|
326
|
+
const failedJobStore = LocalJobStore.getInstance(request.appDir);
|
|
327
|
+
failedJobStore.updateExecutionStatus(request.executionId, JobExecutionStatus.FAILED, {
|
|
328
|
+
message: error.message,
|
|
329
|
+
stack: error.stack
|
|
330
|
+
});
|
|
331
|
+
throw new Error(`Job prepare method failed: ${error.message}`);
|
|
332
|
+
}
|
|
333
|
+
this.sendLog('info', 'Job prepared, starting perform loop...', this.currentRequestId);
|
|
334
|
+
this.sendProgress(this.currentRequestId, 'Executing job', 80);
|
|
335
|
+
// Execute perform loop
|
|
336
|
+
let loopCount = 0;
|
|
337
|
+
const maxLoops = 1000; // Safety limit
|
|
338
|
+
while (!status.complete && loopCount < maxLoops) {
|
|
339
|
+
this.sendLog('debug', `Job perform loop ${loopCount + 1}`, this.currentRequestId);
|
|
340
|
+
try {
|
|
341
|
+
status = await jobInstance.perform(status);
|
|
342
|
+
loopCount++;
|
|
343
|
+
// Check if state changed and save if so
|
|
344
|
+
const newStatusHash = createHash('sha256').update(JSON.stringify(status)).digest('hex');
|
|
345
|
+
if (statusHash !== newStatusHash) {
|
|
346
|
+
jobStore.saveState(request.executionId, status, status.complete || false, newStatusHash, 'perform');
|
|
347
|
+
statusHash = newStatusHash;
|
|
348
|
+
}
|
|
349
|
+
// Update progress
|
|
350
|
+
this.sendProgress(this.currentRequestId, `Job perform loop ${loopCount}`, 80 + (loopCount / maxLoops) * 15);
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
this.sendLog('error', `Job perform failed at loop ${loopCount + 1}: ${error.message}`, this.currentRequestId);
|
|
354
|
+
// Mark job as failed in store
|
|
355
|
+
const { LocalJobStore, JobExecutionStatus } = require('./storage/LocalJobStore');
|
|
356
|
+
const failedJobStore = LocalJobStore.getInstance(request.appDir);
|
|
357
|
+
failedJobStore.updateExecutionStatus(request.executionId, JobExecutionStatus.FAILED, {
|
|
358
|
+
message: error.message,
|
|
359
|
+
stack: error.stack
|
|
360
|
+
});
|
|
361
|
+
throw new Error(`Job perform method failed at loop ${loopCount + 1}: ${error.message}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (loopCount >= maxLoops && !status.complete) {
|
|
365
|
+
// Mark job as failed due to excessive loops
|
|
366
|
+
const { LocalJobStore, JobExecutionStatus } = require('./storage/LocalJobStore');
|
|
367
|
+
const failedJobStore = LocalJobStore.getInstance(request.appDir);
|
|
368
|
+
failedJobStore.updateExecutionStatus(request.executionId, JobExecutionStatus.FAILED, {
|
|
369
|
+
message: `Job exceeded maximum loop count (${maxLoops})`,
|
|
370
|
+
stack: new Error().stack
|
|
371
|
+
});
|
|
372
|
+
throw new Error(`Job exceeded maximum loop count (${maxLoops})`);
|
|
373
|
+
}
|
|
374
|
+
this.sendLog('info', `Job completed after ${loopCount} perform loops`, this.currentRequestId);
|
|
375
|
+
this.sendProgress(this.currentRequestId, 'Job execution completed', 100);
|
|
376
|
+
return {
|
|
377
|
+
success: true,
|
|
378
|
+
result: status,
|
|
379
|
+
loopCount
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Clean up SDK configuration
|
|
384
|
+
* This only happens when the process is shutting down
|
|
385
|
+
*/
|
|
386
|
+
async cleanup() {
|
|
387
|
+
this.sendLog('info', 'Cleaning up unified wrapper');
|
|
388
|
+
if (this.cleanUpLocalSDKs && this.appDir && this.isInitialized) {
|
|
389
|
+
try {
|
|
390
|
+
this.cleanUpLocalSDKs(this.appDir);
|
|
391
|
+
this.sendLog('info', 'SDK cleanup completed');
|
|
392
|
+
this.isInitialized = false;
|
|
393
|
+
}
|
|
394
|
+
catch (error) {
|
|
395
|
+
this.sendLog('warn', `SDK cleanup error: ${error}`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
exports.LocalEngineUnified = LocalEngineUnified;
|
|
401
|
+
// Only execute if this script is run directly (not imported)
|
|
402
|
+
if (require.main === module) {
|
|
403
|
+
const localEngine = new LocalEngineUnified();
|
|
404
|
+
localEngine.start();
|
|
405
|
+
}
|
|
406
|
+
//# sourceMappingURL=local-engine-unified.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-engine-unified.js","sourceRoot":"","sources":["../../../src/local_engine/local-engine-unified.ts"],"names":[],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C,MAAM,EAAE,uBAAuB,SAAS,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC9F,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAiB,EAAE,yBAAyB,EAAE,GAAG,CAAC,CAAC;QAE1E,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,MAAM;YACd,SAAS;SACV,CAAC;IACJ,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,OAAO;QACrB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;QAEpD,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,aAAa,EAAE;YAC9D,IAAI;gBACF,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACnC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;gBAC9C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;aAC5B;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,sBAAsB,KAAK,EAAE,CAAC,CAAC;aACrD;SACF;IACH,CAAC;CACF;AA7cD,gDA6cC;AAED,6DAA6D;AAC7D,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC3B,MAAM,WAAW,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAC7C,WAAW,CAAC,KAAK,EAAE,CAAC;CACrB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IPCMessage, IPCMessageUnion, PendingRequest, IPCConnection } from './local-engine-types';
|
|
4
|
+
/**
|
|
5
|
+
* Generate a unique correlation ID for IPC messages
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateMessageId(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Create a base IPC message with common fields
|
|
10
|
+
*/
|
|
11
|
+
export declare function createBaseMessage(type: string): IPCMessage;
|
|
12
|
+
/**
|
|
13
|
+
* Validate that a message conforms to the IPC schema
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateMessage(message: any): message is IPCMessageUnion;
|
|
16
|
+
/**
|
|
17
|
+
* Send a message through IPC with error handling
|
|
18
|
+
*/
|
|
19
|
+
export declare function sendIPCMessage(process: NodeJS.Process | any, message: IPCMessageUnion): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Create a timeout for pending requests
|
|
22
|
+
*/
|
|
23
|
+
export declare function createRequestTimeout(requestId: string, timeoutMs: number, reject: (error: Error) => void, cleanup: () => void): NodeJS.Timeout;
|
|
24
|
+
/**
|
|
25
|
+
* Safe JSON serialization for IPC messages
|
|
26
|
+
*/
|
|
27
|
+
export declare function safeSerialize(data: any): any;
|
|
28
|
+
/**
|
|
29
|
+
* Log IPC messages for debugging
|
|
30
|
+
*/
|
|
31
|
+
export declare function logIPCMessage(direction: 'SEND' | 'RECV', message: IPCMessageUnion, prefix?: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Create a pending request tracker
|
|
34
|
+
*/
|
|
35
|
+
export declare function createPendingRequest(id: string, type: 'function' | 'lifecycle', resolve: (result: any) => void, reject: (error: Error) => void, timeoutMs?: number): PendingRequest;
|
|
36
|
+
/**
|
|
37
|
+
* Clean up a pending request and its timeout
|
|
38
|
+
*/
|
|
39
|
+
export declare function cleanupPendingRequest(request: PendingRequest): void;
|
|
40
|
+
/**
|
|
41
|
+
* Convert error to serializable format for IPC
|
|
42
|
+
*/
|
|
43
|
+
export declare function serializeError(error: any): {
|
|
44
|
+
message: string;
|
|
45
|
+
stack?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Convert serialized error back to Error object
|
|
50
|
+
*/
|
|
51
|
+
export declare function deserializeError(errorData: {
|
|
52
|
+
message: string;
|
|
53
|
+
stack?: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
}): Error;
|
|
56
|
+
/**
|
|
57
|
+
* Check if IPC connection is healthy
|
|
58
|
+
*/
|
|
59
|
+
export declare function isConnectionHealthy(connection: IPCConnection, maxIdleTime?: number): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Constants for IPC configuration
|
|
62
|
+
*/
|
|
63
|
+
export declare const IPC_CONFIG: {
|
|
64
|
+
readonly DEFAULT_TIMEOUT: 30000;
|
|
65
|
+
readonly MAX_IDLE_TIME: 300000;
|
|
66
|
+
readonly HEARTBEAT_INTERVAL: 60000;
|
|
67
|
+
readonly MAX_MESSAGE_SIZE: number;
|
|
68
|
+
readonly RETRY_ATTEMPTS: 3;
|
|
69
|
+
readonly RETRY_DELAY: 1000;
|
|
70
|
+
};
|