@optimizely/ocp-local-env 1.0.0-beta.10
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 +51 -0
- package/dist/package.json +112 -0
- package/dist/public/bundle.82dc5d29fffb9f205051.js +3 -0
- package/dist/public/bundle.82dc5d29fffb9f205051.js.LICENSE.txt +92 -0
- package/dist/public/bundle.82dc5d29fffb9f205051.js.map +1 -0
- package/dist/public/index.html +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +115 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/executor/DestinationExecutor.d.ts +19 -0
- package/dist/src/executor/DestinationExecutor.js +72 -0
- package/dist/src/executor/DestinationExecutor.js.map +1 -0
- package/dist/src/executor/FunctionExecutor.d.ts +67 -0
- package/dist/src/executor/FunctionExecutor.js +189 -0
- package/dist/src/executor/FunctionExecutor.js.map +1 -0
- package/dist/src/executor/JobExecutor.d.ts +79 -0
- package/dist/src/executor/JobExecutor.js +215 -0
- package/dist/src/executor/JobExecutor.js.map +1 -0
- package/dist/src/executor/LifecycleExecutor.d.ts +64 -0
- package/dist/src/executor/LifecycleExecutor.js +167 -0
- package/dist/src/executor/LifecycleExecutor.js.map +1 -0
- package/dist/src/executor/SourceExecutor.d.ts +32 -0
- package/dist/src/executor/SourceExecutor.js +163 -0
- package/dist/src/executor/SourceExecutor.js.map +1 -0
- package/dist/src/executor/watcher.d.ts +62 -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/LocalFunctionApi.d.ts +17 -0
- package/dist/src/local_engine/LocalFunctionApi.js +54 -0
- package/dist/src/local_engine/LocalFunctionApi.js.map +1 -0
- package/dist/src/local_engine/LocalJobApi.d.ts +67 -0
- package/dist/src/local_engine/LocalJobApi.js +205 -0
- package/dist/src/local_engine/LocalJobApi.js.map +1 -0
- package/dist/src/local_engine/LocalNotifier.d.ts +9 -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 +110 -0
- package/dist/src/local_engine/local-engine-child-base.js +607 -0
- package/dist/src/local_engine/local-engine-child-base.js.map +1 -0
- package/dist/src/local_engine/local-engine-client.d.ts +161 -0
- package/dist/src/local_engine/local-engine-client.js +888 -0
- package/dist/src/local_engine/local-engine-client.js.map +1 -0
- package/dist/src/local_engine/local-engine-types.d.ts +245 -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 +71 -0
- package/dist/src/local_engine/local-engine-unified.js +723 -0
- package/dist/src/local_engine/local-engine-unified.js.map +1 -0
- package/dist/src/local_engine/local-engine-utils.d.ts +68 -0
- package/dist/src/local_engine/local-engine-utils.js +219 -0
- package/dist/src/local_engine/local-engine-utils.js.map +1 -0
- package/dist/src/local_engine/localSDKConfig.d.ts +40 -0
- package/dist/src/local_engine/localSDKConfig.js +247 -0
- package/dist/src/local_engine/localSDKConfig.js.map +1 -0
- package/dist/src/local_engine/storage/BaseKVStoreWrapper.d.ts +37 -0
- package/dist/src/local_engine/storage/BaseKVStoreWrapper.js +110 -0
- package/dist/src/local_engine/storage/BaseKVStoreWrapper.js.map +1 -0
- package/dist/src/local_engine/storage/LocalConfigStore.d.ts +74 -0
- package/dist/src/local_engine/storage/LocalConfigStore.js +178 -0
- package/dist/src/local_engine/storage/LocalConfigStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalJobStore.d.ts +111 -0
- package/dist/src/local_engine/storage/LocalJobStore.js +249 -0
- package/dist/src/local_engine/storage/LocalJobStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalKVStore.d.ts +106 -0
- package/dist/src/local_engine/storage/LocalKVStore.js +1061 -0
- package/dist/src/local_engine/storage/LocalKVStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.d.ts +28 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.js +149 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.d.ts +115 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.js +350 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalSecretsStoreWrapper.d.ts +19 -0
- package/dist/src/local_engine/storage/LocalSecretsStoreWrapper.js +52 -0
- package/dist/src/local_engine/storage/LocalSecretsStoreWrapper.js.map +1 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.d.ts +168 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.js +509 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalSettingsStoreWrapper.d.ts +15 -0
- package/dist/src/local_engine/storage/LocalSettingsStoreWrapper.js +28 -0
- package/dist/src/local_engine/storage/LocalSettingsStoreWrapper.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/SourceDataStore.d.ts +23 -0
- package/dist/src/local_engine/storage/SourceDataStore.js +83 -0
- package/dist/src/local_engine/storage/SourceDataStore.js.map +1 -0
- package/dist/src/local_engine/storage/SourceJobExecutionStore.d.ts +25 -0
- package/dist/src/local_engine/storage/SourceJobExecutionStore.js +61 -0
- package/dist/src/local_engine/storage/SourceJobExecutionStore.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 +53 -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 +33 -0
- package/dist/src/local_engine/utils.js +143 -0
- package/dist/src/local_engine/utils.js.map +1 -0
- package/dist/src/logging/LogManager.d.ts +246 -0
- package/dist/src/logging/LogManager.js +343 -0
- package/dist/src/logging/LogManager.js.map +1 -0
- package/dist/src/server/api/destinations.d.ts +7 -0
- package/dist/src/server/api/destinations.js +170 -0
- package/dist/src/server/api/destinations.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 +10 -0
- package/dist/src/server/api/jobs.js +244 -0
- package/dist/src/server/api/jobs.js.map +1 -0
- package/dist/src/server/api/settings.d.ts +6 -0
- package/dist/src/server/api/settings.js +116 -0
- package/dist/src/server/api/settings.js.map +1 -0
- package/dist/src/server/api/sources.d.ts +7 -0
- package/dist/src/server/api/sources.js +382 -0
- package/dist/src/server/api/sources.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 +718 -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 +217 -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 +113 -0
- package/dist/src/server/app-discovery.js.map +1 -0
- package/dist/src/server/config.d.ts +26 -0
- package/dist/src/server/config.js +112 -0
- package/dist/src/server/config.js.map +1 -0
- package/dist/src/server/mockDataGenerator.d.ts +1 -0
- package/dist/src/server/mockDataGenerator.js +154 -0
- package/dist/src/server/mockDataGenerator.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 +735 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/types/app.d.ts +154 -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 +432 -0
- package/dist/src/ui/components/App.js.map +1 -0
- package/dist/src/ui/components/DestinationBatchEditor.d.ts +7 -0
- package/dist/src/ui/components/DestinationBatchEditor.js +160 -0
- package/dist/src/ui/components/DestinationBatchEditor.js.map +1 -0
- package/dist/src/ui/components/DestinationSchemaViewer.d.ts +7 -0
- package/dist/src/ui/components/DestinationSchemaViewer.js +61 -0
- package/dist/src/ui/components/DestinationSchemaViewer.js.map +1 -0
- package/dist/src/ui/components/DestinationsView.d.ts +14 -0
- package/dist/src/ui/components/DestinationsView.js +68 -0
- package/dist/src/ui/components/DestinationsView.js.map +1 -0
- package/dist/src/ui/components/FunctionsView.d.ts +13 -0
- package/dist/src/ui/components/FunctionsView.js +288 -0
- package/dist/src/ui/components/FunctionsView.js.map +1 -0
- package/dist/src/ui/components/JobsView.d.ts +13 -0
- package/dist/src/ui/components/JobsView.js +320 -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/MetadataModal.d.ts +14 -0
- package/dist/src/ui/components/MetadataModal.js +28 -0
- package/dist/src/ui/components/MetadataModal.js.map +1 -0
- package/dist/src/ui/components/MetadataModal.test.d.ts +1 -0
- package/dist/src/ui/components/MetadataModal.test.js +143 -0
- package/dist/src/ui/components/MetadataModal.test.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/SourceDataViewer.d.ts +8 -0
- package/dist/src/ui/components/SourceDataViewer.js +84 -0
- package/dist/src/ui/components/SourceDataViewer.js.map +1 -0
- package/dist/src/ui/components/SourceJobsSection.d.ts +8 -0
- package/dist/src/ui/components/SourceJobsSection.js +99 -0
- package/dist/src/ui/components/SourceJobsSection.js.map +1 -0
- package/dist/src/ui/components/SourceLifecycleSection.d.ts +7 -0
- package/dist/src/ui/components/SourceLifecycleSection.js +58 -0
- package/dist/src/ui/components/SourceLifecycleSection.js.map +1 -0
- package/dist/src/ui/components/SourceSchemaViewer.d.ts +7 -0
- package/dist/src/ui/components/SourceSchemaViewer.js +65 -0
- package/dist/src/ui/components/SourceSchemaViewer.js.map +1 -0
- package/dist/src/ui/components/SourceWebhookEditor.d.ts +8 -0
- package/dist/src/ui/components/SourceWebhookEditor.js +181 -0
- package/dist/src/ui/components/SourceWebhookEditor.js.map +1 -0
- package/dist/src/ui/components/SourcesView.d.ts +14 -0
- package/dist/src/ui/components/SourcesView.js +74 -0
- package/dist/src/ui/components/SourcesView.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 +17 -0
- package/dist/src/ui/components/TabbedConsole.js +163 -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/hooks/useEntityNavigation.d.ts +72 -0
- package/dist/src/ui/hooks/useEntityNavigation.js +150 -0
- package/dist/src/ui/hooks/useEntityNavigation.js.map +1 -0
- package/dist/src/ui/hooks/useQueryParams.d.ts +6 -0
- package/dist/src/ui/hooks/useQueryParams.js +39 -0
- package/dist/src/ui/hooks/useQueryParams.js.map +1 -0
- package/dist/src/ui/index.d.ts +1 -0
- package/dist/src/ui/index.js +23 -0
- package/dist/src/ui/index.js.map +1 -0
- package/dist/src/ui/store/formStateSlice.d.ts +54 -0
- package/dist/src/ui/store/formStateSlice.js +94 -0
- package/dist/src/ui/store/formStateSlice.js.map +1 -0
- package/dist/src/ui/store/hooks.d.ts +6 -0
- package/dist/src/ui/store/hooks.js +8 -0
- package/dist/src/ui/store/hooks.js.map +1 -0
- package/dist/src/ui/store/index.d.ts +11 -0
- package/dist/src/ui/store/index.js +107 -0
- package/dist/src/ui/store/index.js.map +1 -0
- package/dist/src/utils/functionEndpoints.d.ts +24 -0
- package/dist/src/utils/functionEndpoints.js +45 -0
- package/dist/src/utils/functionEndpoints.js.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>OCP Local Testing Tool</title><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"><script defer="defer" src="/bundle.82dc5d29fffb9f205051.js"></script></head><body><div id="root"></div></body></html>
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const commander_1 = require("commander");
|
|
38
|
+
const package_json_1 = require("../package.json");
|
|
39
|
+
// Create the command line interface
|
|
40
|
+
const program = new commander_1.Command();
|
|
41
|
+
program
|
|
42
|
+
.name('ocp-local-env')
|
|
43
|
+
.description('Local testing environment for Optimizely Connect Platform (OCP) applications')
|
|
44
|
+
.version(package_json_1.version)
|
|
45
|
+
.option("-p, --port <port>", "Port to run the server on", "3000")
|
|
46
|
+
.option("-c, --config <path>", "Path to custom config file")
|
|
47
|
+
.option("--path <path>", "Path to the OCP app root directory")
|
|
48
|
+
.option("-v, --verbose", "Enable verbose logging")
|
|
49
|
+
.option("--no-open", "Don't automatically open browser");
|
|
50
|
+
program
|
|
51
|
+
.command("start")
|
|
52
|
+
.description("Start the local testing environment")
|
|
53
|
+
.option("-p, --port <port>", "Port to run the server on", "3000")
|
|
54
|
+
.option("-c, --config <path>", "Path to custom config file")
|
|
55
|
+
.option("--path <path>", "Path to the OCP app root directory")
|
|
56
|
+
.option("-v, --verbose", "Enable verbose logging")
|
|
57
|
+
.option("--no-open", "Don't automatically open browser")
|
|
58
|
+
.action(async (options) => {
|
|
59
|
+
await runServer(options);
|
|
60
|
+
});
|
|
61
|
+
program
|
|
62
|
+
.command('create')
|
|
63
|
+
.description('Create a new OCP app from a template')
|
|
64
|
+
.argument('<name>', 'Name of the app to create')
|
|
65
|
+
.option('-t, --template <template>', 'Template to use', 'basic')
|
|
66
|
+
.action((name, options) => {
|
|
67
|
+
console.log(`Creating new OCP app: ${name} (using template: ${options.template})`);
|
|
68
|
+
console.log('This feature is not yet implemented.');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
});
|
|
71
|
+
program
|
|
72
|
+
.command('validate')
|
|
73
|
+
.description('Validate an existing OCP app')
|
|
74
|
+
.option('-p, --path <path>', 'Path to the app directory', '.')
|
|
75
|
+
.action((options) => {
|
|
76
|
+
console.log(`Validating OCP app in: ${options.path}`);
|
|
77
|
+
console.log('This feature is not yet implemented.');
|
|
78
|
+
process.exit(1);
|
|
79
|
+
});
|
|
80
|
+
program
|
|
81
|
+
.command('help')
|
|
82
|
+
.description('Display help information')
|
|
83
|
+
.action(() => {
|
|
84
|
+
program.help();
|
|
85
|
+
});
|
|
86
|
+
// Default action when no command is provided
|
|
87
|
+
program.action(async (options) => {
|
|
88
|
+
await runServer(options);
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* Set environment variables from CLI options and start the server.
|
|
92
|
+
* Uses dynamic import to ensure config module reads env vars after they're set.
|
|
93
|
+
*/
|
|
94
|
+
async function runServer(options) {
|
|
95
|
+
try {
|
|
96
|
+
// Set environment variables BEFORE importing server module
|
|
97
|
+
process.env.OCP_LOCAL_PORT = options.port;
|
|
98
|
+
process.env.OCP_LOCAL_CONFIG_PATH = options.config;
|
|
99
|
+
process.env.OCP_LOCAL_VERBOSE = options.verbose ? "true" : "false";
|
|
100
|
+
process.env.OCP_LOCAL_OPEN_BROWSER = options.open ? "true" : "false";
|
|
101
|
+
if (options.path) {
|
|
102
|
+
process.env.APP_ROOT_DIR = options.path;
|
|
103
|
+
}
|
|
104
|
+
// Dynamic import ensures config module is loaded AFTER env vars are set
|
|
105
|
+
const { startServer } = await Promise.resolve().then(() => __importStar(require('./server')));
|
|
106
|
+
await startServer();
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
console.error("Failed to start server:", error);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Parse command line arguments
|
|
114
|
+
program.parse(process.argv);
|
|
115
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAAoC;AACpC,kDAA0C;AAE1C,oCAAoC;AACpC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;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AAC;QAC1C,CAAC;QAED,wEAAwE;QACxE,MAAM,EAAE,WAAW,EAAE,GAAG,wDAAa,UAAU,GAAC,CAAC;QACjD,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,+BAA+B;AAC/B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { App } from '../types/app';
|
|
2
|
+
import { AppWatcher } from './watcher';
|
|
3
|
+
export interface DestinationReadyResult {
|
|
4
|
+
ready: boolean;
|
|
5
|
+
message?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DestinationDeliverResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
retryable?: boolean;
|
|
10
|
+
failureReason?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class DestinationExecutor {
|
|
13
|
+
private app;
|
|
14
|
+
private localEngineClient;
|
|
15
|
+
private watcher?;
|
|
16
|
+
constructor(app: App, watcher?: AppWatcher);
|
|
17
|
+
executeReady(destinationId: string): Promise<DestinationReadyResult>;
|
|
18
|
+
executeDeliver(destinationId: string, batch: any): Promise<DestinationDeliverResult>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DestinationExecutor = void 0;
|
|
4
|
+
const local_engine_client_1 = require("../local_engine/local-engine-client");
|
|
5
|
+
const LogManager_1 = require("../logging/LogManager");
|
|
6
|
+
const config_1 = require("../server/config");
|
|
7
|
+
const logger = LogManager_1.LogManager.getInstance();
|
|
8
|
+
/**
|
|
9
|
+
* Create app configuration object for IPC communication
|
|
10
|
+
*/
|
|
11
|
+
function createAppConfig(app) {
|
|
12
|
+
return {
|
|
13
|
+
manifest: app.manifest,
|
|
14
|
+
isBuilt: true,
|
|
15
|
+
isValid: true,
|
|
16
|
+
path: app.path,
|
|
17
|
+
baseUrl: `http://${config_1.config.server.host}:${config_1.config.server.port}`
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
class DestinationExecutor {
|
|
21
|
+
constructor(app, watcher) {
|
|
22
|
+
this.app = app;
|
|
23
|
+
this.localEngineClient = local_engine_client_1.LocalEngineClient.getInstance();
|
|
24
|
+
this.watcher = watcher;
|
|
25
|
+
// Listen for build success events to reload code
|
|
26
|
+
if (this.watcher) {
|
|
27
|
+
this.watcher.on('buildSuccess', () => {
|
|
28
|
+
console.log('[DestinationExecutor] Build succeeded, closing connections to reload code');
|
|
29
|
+
this.localEngineClient.closeAllConnections().catch(err => {
|
|
30
|
+
console.error('[DestinationExecutor] Error closing connections:', err);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async executeReady(destinationId) {
|
|
36
|
+
try {
|
|
37
|
+
logger.logDestinationExecution(destinationId, 'ready', 'started');
|
|
38
|
+
const destination = this.app.manifest.destinations?.[destinationId];
|
|
39
|
+
if (!destination) {
|
|
40
|
+
throw new Error(`Destination ${destinationId} not found in manifest`);
|
|
41
|
+
}
|
|
42
|
+
const result = await this.localEngineClient.executeDestinationReady(destinationId, createAppConfig(this.app));
|
|
43
|
+
logger.logDestinationExecution(destinationId, 'ready', 'success', { ready: result.ready });
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger.logDestinationExecution(destinationId, 'ready', 'error', { error });
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async executeDeliver(destinationId, batch) {
|
|
52
|
+
try {
|
|
53
|
+
logger.logDestinationExecution(destinationId, 'deliver', 'started', { batchSize: batch?.length });
|
|
54
|
+
const destination = this.app.manifest.destinations?.[destinationId];
|
|
55
|
+
if (!destination) {
|
|
56
|
+
throw new Error(`Destination ${destinationId} not found in manifest`);
|
|
57
|
+
}
|
|
58
|
+
const result = await this.localEngineClient.executeDestinationDeliver(destinationId, batch, createAppConfig(this.app));
|
|
59
|
+
logger.logDestinationExecution(destinationId, 'deliver', 'success', {
|
|
60
|
+
batchSize: batch?.length,
|
|
61
|
+
retryable: result.retryable
|
|
62
|
+
});
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
logger.logDestinationExecution(destinationId, 'deliver', 'error', { error });
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.DestinationExecutor = DestinationExecutor;
|
|
72
|
+
//# sourceMappingURL=DestinationExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DestinationExecutor.js","sourceRoot":"","sources":["../../../src/executor/DestinationExecutor.ts"],"names":[],"mappings":";;;AACA,6EAAwE;AACxE,sDAAmD;AAEnD,6CAA0C;AAE1C,MAAM,MAAM,GAAG,uBAAU,CAAC,WAAW,EAAE,CAAC;AAaxC;;GAEG;AACH,SAAS,eAAe,CAAC,GAAQ;IAC/B,OAAO;QACL,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,UAAU,eAAM,CAAC,MAAM,CAAC,IAAI,IAAI,eAAM,CAAC,MAAM,CAAC,IAAI,EAAE;KAC9D,CAAC;AACJ,CAAC;AAED,MAAa,mBAAmB;IAK9B,YAAY,GAAQ,EAAE,OAAoB;QACxC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,iBAAiB,GAAG,uCAAiB,CAAC,WAAW,EAAE,CAAC;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,CAA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,EACrB,KAAU;QAEV,IAAI,CAAC;YACH,MAAM,CAAC,uBAAuB,CAAC,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YAElG,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,aAAa,CAAC,CAAC;YACpE,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,eAAe,aAAa,wBAAwB,CAAC,CAAC;YACxE,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,yBAAyB,CACnE,aAAa,EACb,KAAK,EACL,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAC1B,CAAC;YAEF,MAAM,CAAC,uBAAuB,CAAC,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE;gBAClE,SAAS,EAAE,KAAK,EAAE,MAAM;gBACxB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,uBAAuB,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAvED,kDAuEC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { App } from '../types/app';
|
|
2
|
+
import { LocalSettingsStore } from '../local_engine/storage/LocalSettingsStore';
|
|
3
|
+
import { AppWatcher } from './watcher';
|
|
4
|
+
/**
|
|
5
|
+
* Function execution request data
|
|
6
|
+
*/
|
|
7
|
+
export interface FunctionExecutionRequest {
|
|
8
|
+
functionId: string;
|
|
9
|
+
method: string;
|
|
10
|
+
fullpath: string;
|
|
11
|
+
path: string;
|
|
12
|
+
params: Record<string, any>;
|
|
13
|
+
headers: [string, string][];
|
|
14
|
+
body: any;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Function execution response
|
|
18
|
+
*/
|
|
19
|
+
export interface FunctionExecutionResponse {
|
|
20
|
+
success: boolean;
|
|
21
|
+
status?: number;
|
|
22
|
+
headers?: [string, string][];
|
|
23
|
+
body?: any;
|
|
24
|
+
logs: string[];
|
|
25
|
+
error?: {
|
|
26
|
+
message: string;
|
|
27
|
+
stack?: string;
|
|
28
|
+
};
|
|
29
|
+
executionTime: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Account configuration for local testing
|
|
33
|
+
*/
|
|
34
|
+
export interface AccountConfig {
|
|
35
|
+
organizationId?: string;
|
|
36
|
+
instanceId?: string;
|
|
37
|
+
trackerId?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Executes functions of an OCP app in isolated processes
|
|
41
|
+
*/
|
|
42
|
+
export declare class FunctionExecutor {
|
|
43
|
+
private appDir;
|
|
44
|
+
private app;
|
|
45
|
+
private settingsStore;
|
|
46
|
+
private configStore;
|
|
47
|
+
private localEngineClient;
|
|
48
|
+
private accountConfig?;
|
|
49
|
+
private watcher?;
|
|
50
|
+
constructor(appDir: string, app: App, settingsStore: LocalSettingsStore, configStore: any, accountConfig?: AccountConfig, watcher?: AppWatcher);
|
|
51
|
+
/**
|
|
52
|
+
* Execute a function with the given request data
|
|
53
|
+
*/
|
|
54
|
+
executeFunction(request: FunctionExecutionRequest): Promise<FunctionExecutionResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Get the path to the built function file
|
|
57
|
+
*/
|
|
58
|
+
private getFunctionPath;
|
|
59
|
+
/**
|
|
60
|
+
* Execute the function script using IPC
|
|
61
|
+
*/
|
|
62
|
+
private executeFunctionScript;
|
|
63
|
+
/**
|
|
64
|
+
* Cleanup IPC connections when executor is destroyed
|
|
65
|
+
*/
|
|
66
|
+
cleanup(): Promise<void>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FunctionExecutor = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const LogManager_1 = require("../logging/LogManager");
|
|
9
|
+
const local_engine_client_1 = require("../local_engine/local-engine-client");
|
|
10
|
+
const config_1 = require("../server/config");
|
|
11
|
+
/**
|
|
12
|
+
* Executes functions of an OCP app in isolated processes
|
|
13
|
+
*/
|
|
14
|
+
class FunctionExecutor {
|
|
15
|
+
constructor(appDir, app, settingsStore, configStore, accountConfig, watcher) {
|
|
16
|
+
this.appDir = appDir;
|
|
17
|
+
this.app = app;
|
|
18
|
+
this.settingsStore = settingsStore;
|
|
19
|
+
this.configStore = configStore;
|
|
20
|
+
this.localEngineClient = local_engine_client_1.LocalEngineClient.getInstance();
|
|
21
|
+
this.accountConfig = accountConfig;
|
|
22
|
+
this.watcher = watcher;
|
|
23
|
+
// Listen for build success events to reload code
|
|
24
|
+
if (this.watcher) {
|
|
25
|
+
this.watcher.on('buildSuccess', () => {
|
|
26
|
+
console.log('[FunctionExecutor] Build succeeded, closing connections to reload code');
|
|
27
|
+
this.localEngineClient.closeAllConnections().catch(err => {
|
|
28
|
+
console.error('[FunctionExecutor] Error closing connections:', err);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Execute a function with the given request data
|
|
35
|
+
*/
|
|
36
|
+
async executeFunction(request) {
|
|
37
|
+
const logManager = LogManager_1.LogManager.getInstance();
|
|
38
|
+
const startTime = Date.now();
|
|
39
|
+
const logs = [];
|
|
40
|
+
// Log function execution start
|
|
41
|
+
logManager.logFunctionExecution(request.functionId, 'started', {
|
|
42
|
+
method: request.method,
|
|
43
|
+
path: request.path
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
// Validate function exists
|
|
47
|
+
const functions = this.app.manifest.functions || {};
|
|
48
|
+
if (!functions[request.functionId]) {
|
|
49
|
+
throw new Error(`Function '${request.functionId}' not found in app manifest`);
|
|
50
|
+
}
|
|
51
|
+
const functionDef = functions[request.functionId];
|
|
52
|
+
// Check if built function file exists
|
|
53
|
+
const functionPath = this.getFunctionPath(functionDef.entry_point);
|
|
54
|
+
// Execute the function script
|
|
55
|
+
const executionResult = await this.executeFunctionScript(request, functionPath);
|
|
56
|
+
const executionTime = Date.now() - startTime;
|
|
57
|
+
if (executionResult.success) {
|
|
58
|
+
logs.push(`Function ${request.functionId} execution started`);
|
|
59
|
+
logs.push(...executionResult.logs);
|
|
60
|
+
logs.push(`Function ${request.functionId} execution completed successfully`);
|
|
61
|
+
// Log function execution success
|
|
62
|
+
logManager.logFunctionExecution(request.functionId, 'success', {
|
|
63
|
+
executionTime,
|
|
64
|
+
status: executionResult.status
|
|
65
|
+
});
|
|
66
|
+
// Log function output to centralized logging
|
|
67
|
+
logManager.logFunctionOutput(request.functionId, executionResult.logs.join('\n'));
|
|
68
|
+
return {
|
|
69
|
+
success: true,
|
|
70
|
+
status: executionResult.status,
|
|
71
|
+
headers: executionResult.headers,
|
|
72
|
+
body: executionResult.body,
|
|
73
|
+
logs,
|
|
74
|
+
executionTime,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
logs.push(`Function ${request.functionId} execution started`);
|
|
79
|
+
logs.push(...executionResult.logs);
|
|
80
|
+
logs.push(`Function ${request.functionId} execution failed: ${executionResult.error}`);
|
|
81
|
+
// Log function execution error
|
|
82
|
+
logManager.logFunctionExecution(request.functionId, 'error', {
|
|
83
|
+
executionTime,
|
|
84
|
+
error: executionResult.error
|
|
85
|
+
});
|
|
86
|
+
// Log function output to centralized logging
|
|
87
|
+
logManager.logFunctionOutput(request.functionId, executionResult.logs.join('\n'));
|
|
88
|
+
if (executionResult.error) {
|
|
89
|
+
logManager.logFunctionOutput(request.functionId, executionResult.error, true);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
success: false,
|
|
93
|
+
logs,
|
|
94
|
+
error: {
|
|
95
|
+
message: executionResult.error || "Function execution failed",
|
|
96
|
+
stack: executionResult.stack,
|
|
97
|
+
},
|
|
98
|
+
executionTime,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
const executionTime = Date.now() - startTime;
|
|
104
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
105
|
+
logs.push(`Function ${request.functionId} execution started`);
|
|
106
|
+
logs.push(`Error executing ${request.functionId}: ${errorMessage}`);
|
|
107
|
+
// Log function execution error
|
|
108
|
+
logManager.logFunctionExecution(request.functionId, 'error', {
|
|
109
|
+
executionTime,
|
|
110
|
+
error: errorMessage,
|
|
111
|
+
stack: error instanceof Error ? error.stack : undefined
|
|
112
|
+
});
|
|
113
|
+
// Log error to centralized logging
|
|
114
|
+
logManager.logFunctionOutput(request.functionId, errorMessage, true);
|
|
115
|
+
return {
|
|
116
|
+
success: false,
|
|
117
|
+
logs,
|
|
118
|
+
error: {
|
|
119
|
+
message: errorMessage,
|
|
120
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
121
|
+
},
|
|
122
|
+
executionTime,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get the path to the built function file
|
|
128
|
+
*/
|
|
129
|
+
getFunctionPath(entryPoint) {
|
|
130
|
+
// Try different possible locations for the built function
|
|
131
|
+
const possiblePaths = [
|
|
132
|
+
path_1.default.join(this.appDir, "dist", "functions", `${entryPoint}.js`),
|
|
133
|
+
path_1.default.join(this.appDir, "dist", "src", "functions", `${entryPoint}.js`),
|
|
134
|
+
path_1.default.join(this.appDir, "dist", `${entryPoint}.js`),
|
|
135
|
+
];
|
|
136
|
+
return possiblePaths[0]; // For now, use the first path - will validate existence in wrapper script
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Execute the function script using IPC
|
|
140
|
+
*/
|
|
141
|
+
async executeFunctionScript(request, _scriptPath) {
|
|
142
|
+
try {
|
|
143
|
+
// Convert request to IPC format
|
|
144
|
+
const ipcRequest = {
|
|
145
|
+
functionId: request.functionId,
|
|
146
|
+
method: request.method,
|
|
147
|
+
fullpath: request.fullpath,
|
|
148
|
+
path: request.path,
|
|
149
|
+
params: request.params,
|
|
150
|
+
headers: request.headers,
|
|
151
|
+
body: request.body
|
|
152
|
+
};
|
|
153
|
+
// Prepare app config for IPC
|
|
154
|
+
const appConfig = {
|
|
155
|
+
manifest: this.app.manifest,
|
|
156
|
+
path: this.appDir,
|
|
157
|
+
isBuilt: true,
|
|
158
|
+
isValid: true,
|
|
159
|
+
account: this.accountConfig,
|
|
160
|
+
baseUrl: `http://${config_1.config.server.host}:${config_1.config.server.port}`
|
|
161
|
+
};
|
|
162
|
+
// Execute via IPC
|
|
163
|
+
const result = await this.localEngineClient.executeFunction(ipcRequest, appConfig, this.appDir);
|
|
164
|
+
return {
|
|
165
|
+
success: result.success || true,
|
|
166
|
+
status: result.status,
|
|
167
|
+
headers: result.headers,
|
|
168
|
+
body: result.body,
|
|
169
|
+
logs: [] // IPC handles logging separately
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
return {
|
|
174
|
+
success: false,
|
|
175
|
+
logs: [],
|
|
176
|
+
error: error.message,
|
|
177
|
+
stack: error.stack
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Cleanup IPC connections when executor is destroyed
|
|
183
|
+
*/
|
|
184
|
+
async cleanup() {
|
|
185
|
+
await this.localEngineClient.closeAllConnections();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.FunctionExecutor = FunctionExecutor;
|
|
189
|
+
//# sourceMappingURL=FunctionExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionExecutor.js","sourceRoot":"","sources":["../../../src/executor/FunctionExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,sDAAmD;AACnD,6EAAwE;AAGxE,6CAA0C;AAyC1C;;GAEG;AACH,MAAa,gBAAgB;IAS3B,YAAY,MAAc,EAAE,GAAQ,EAAE,aAAiC,EAAE,WAAgB,EAAE,aAA6B,EAAE,OAAoB;QAC5I,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,iBAAiB,GAAG,uCAAiB,CAAC,WAAW,EAAE,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,iDAAiD;QACjD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;gBACnC,OAAO,CAAC,GAAG,CAAC,wEAAwE,CAAC,CAAC;gBACtF,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACvD,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,GAAG,CAAC,CAAC;gBACtE,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,eAAe,CAAC,OAAiC;QAC5D,MAAM,UAAU,GAAG,uBAAU,CAAC,WAAW,EAAE,CAAC;QAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAa,EA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AI;gBACjB,IAAI,EAAE,EAAE,CAAC,iCAAiC;aAC3C,CAAC;QAEJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,EAAE;gBACR,KAAK,EAAE,KAAK,CAAC,OAAO;gBACpB,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC;QACJ,CAAC;IACH,CAAC;IAGD;;OAEG;IACI,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,CAAC;IACrD,CAAC;CACF;AA5ND,4CA4NC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { App, JobDefinition, JobExecutionRequest, JobExecutionResponse } from '../types/app';
|
|
2
|
+
import { JobExecution } from '../local_engine/storage/LocalJobStore';
|
|
3
|
+
import { AppWatcher } from './watcher';
|
|
4
|
+
/**
|
|
5
|
+
* Account configuration for local testing
|
|
6
|
+
*/
|
|
7
|
+
export interface AccountConfig {
|
|
8
|
+
organizationId?: string;
|
|
9
|
+
instanceId?: string;
|
|
10
|
+
trackerId?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Account configuration for local testing
|
|
14
|
+
*/
|
|
15
|
+
export interface AccountConfig {
|
|
16
|
+
organizationId?: string;
|
|
17
|
+
instanceId?: string;
|
|
18
|
+
trackerId?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Executes jobs of an OCP app in isolated processes
|
|
22
|
+
*/
|
|
23
|
+
export declare class JobExecutor {
|
|
24
|
+
private appDir;
|
|
25
|
+
private app;
|
|
26
|
+
private jobStore;
|
|
27
|
+
private localEngineClient;
|
|
28
|
+
private accountConfig?;
|
|
29
|
+
private watcher?;
|
|
30
|
+
constructor(appDir: string, app: App, accountConfig?: AccountConfig, watcher?: AppWatcher);
|
|
31
|
+
/**
|
|
32
|
+
* Get job definitions from app manifest
|
|
33
|
+
*/
|
|
34
|
+
getJobs(): JobDefinition[];
|
|
35
|
+
/**
|
|
36
|
+
* Get job execution history
|
|
37
|
+
*/
|
|
38
|
+
getExecutions(jobId?: string): JobExecution[];
|
|
39
|
+
/**
|
|
40
|
+
* Get specific execution details
|
|
41
|
+
*/
|
|
42
|
+
getExecution(executionId: string): JobExecution | null;
|
|
43
|
+
/**
|
|
44
|
+
* Get execution state history
|
|
45
|
+
*/
|
|
46
|
+
getExecutionStates(executionId: string): import("../local_engine/storage/LocalJobStore").JobStateSnapshot[];
|
|
47
|
+
/**
|
|
48
|
+
* Start a job execution
|
|
49
|
+
*/
|
|
50
|
+
executeJob(request: JobExecutionRequest): Promise<JobExecutionResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Execute job asynchronously in the background
|
|
53
|
+
*/
|
|
54
|
+
private executeJobAsync;
|
|
55
|
+
/**
|
|
56
|
+
* Check if job file exists and is built
|
|
57
|
+
*/
|
|
58
|
+
validateJob(jobId: string): {
|
|
59
|
+
valid: boolean;
|
|
60
|
+
error?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Get job statistics
|
|
64
|
+
*/
|
|
65
|
+
getStats(): {
|
|
66
|
+
totalExecutions: number;
|
|
67
|
+
runningExecutions: number;
|
|
68
|
+
completedExecutions: number;
|
|
69
|
+
failedExecutions: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Clean up old job executions
|
|
73
|
+
*/
|
|
74
|
+
cleanup(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Cleanup local engine connections when executor is destroyed
|
|
77
|
+
*/
|
|
78
|
+
dispose(): Promise<void>;
|
|
79
|
+
}
|