@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,83 @@
|
|
|
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.SourceDataStore = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
class SourceDataStore {
|
|
10
|
+
constructor(appRootDir) {
|
|
11
|
+
this.maxEntries = 50;
|
|
12
|
+
this.storageDir = path_1.default.join(appRootDir, 'storage', 'source-data');
|
|
13
|
+
this.ensureStorageDir();
|
|
14
|
+
}
|
|
15
|
+
ensureStorageDir() {
|
|
16
|
+
if (!fs_1.default.existsSync(this.storageDir)) {
|
|
17
|
+
fs_1.default.mkdirSync(this.storageDir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
getFilePath(sourceId) {
|
|
21
|
+
return path_1.default.join(this.storageDir, `${sourceId}.json`);
|
|
22
|
+
}
|
|
23
|
+
readFile(sourceId) {
|
|
24
|
+
const filePath = this.getFilePath(sourceId);
|
|
25
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
26
|
+
return { sourceId, entries: [] };
|
|
27
|
+
}
|
|
28
|
+
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
29
|
+
return JSON.parse(content);
|
|
30
|
+
}
|
|
31
|
+
writeFile(data) {
|
|
32
|
+
const filePath = this.getFilePath(data.sourceId);
|
|
33
|
+
fs_1.default.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
34
|
+
}
|
|
35
|
+
push(sourceId, data, context, metadata) {
|
|
36
|
+
const file = this.readFile(sourceId);
|
|
37
|
+
// Add new entry
|
|
38
|
+
file.entries.push({
|
|
39
|
+
timestamp: Date.now(),
|
|
40
|
+
data,
|
|
41
|
+
context,
|
|
42
|
+
metadata
|
|
43
|
+
});
|
|
44
|
+
// Prune to keep only last maxEntries per context
|
|
45
|
+
const webhookEntries = file.entries.filter(e => e.context === 'webhook');
|
|
46
|
+
const jobEntries = file.entries.filter(e => e.context === 'job');
|
|
47
|
+
// Keep last maxEntries for each context
|
|
48
|
+
const prunedWebhook = webhookEntries.slice(-this.maxEntries);
|
|
49
|
+
const prunedJob = jobEntries.slice(-this.maxEntries);
|
|
50
|
+
// Merge and sort by timestamp
|
|
51
|
+
file.entries = [...prunedWebhook, ...prunedJob].sort((a, b) => a.timestamp - b.timestamp);
|
|
52
|
+
this.writeFile(file);
|
|
53
|
+
}
|
|
54
|
+
getData(sourceId, context, limit) {
|
|
55
|
+
const file = this.readFile(sourceId);
|
|
56
|
+
let entries = file.entries;
|
|
57
|
+
// Filter by context if specified
|
|
58
|
+
if (context) {
|
|
59
|
+
entries = entries.filter(e => e.context === context);
|
|
60
|
+
}
|
|
61
|
+
if (limit && limit > 0) {
|
|
62
|
+
return entries.slice(-limit);
|
|
63
|
+
}
|
|
64
|
+
return entries;
|
|
65
|
+
}
|
|
66
|
+
clear(sourceId, context) {
|
|
67
|
+
if (!context) {
|
|
68
|
+
// Clear all data
|
|
69
|
+
const filePath = this.getFilePath(sourceId);
|
|
70
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
71
|
+
fs_1.default.unlinkSync(filePath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Clear only specific context
|
|
76
|
+
const file = this.readFile(sourceId);
|
|
77
|
+
file.entries = file.entries.filter(e => e.context !== context);
|
|
78
|
+
this.writeFile(file);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.SourceDataStore = SourceDataStore;
|
|
83
|
+
//# sourceMappingURL=SourceDataStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceDataStore.js","sourceRoot":"","sources":["../../../../src/local_engine/storage/SourceDataStore.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAgBpB,MAAa,eAAe;IAI1B,YAAY,UAAkB;QAFtB,eAAU,GAAW,EAAE,CAAC;QAG9B,IAAI,CAAC,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;QAClE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;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,QAAgB,EAAE,OAA2B;QACjD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,iBAAiB;YACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,8BAA8B;YAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;YAC/D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAxFD,0CAwFC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface SourceJobExecution {
|
|
2
|
+
jobId: string;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
success: boolean;
|
|
5
|
+
logs: string[];
|
|
6
|
+
executionTime: number;
|
|
7
|
+
error?: string;
|
|
8
|
+
result?: any;
|
|
9
|
+
}
|
|
10
|
+
export interface SourceJobExecutionFile {
|
|
11
|
+
sourceId: string;
|
|
12
|
+
executions: SourceJobExecution[];
|
|
13
|
+
}
|
|
14
|
+
export declare class SourceJobExecutionStore {
|
|
15
|
+
private storageDir;
|
|
16
|
+
private maxExecutions;
|
|
17
|
+
constructor(appRootDir: string);
|
|
18
|
+
private ensureStorageDir;
|
|
19
|
+
private getFilePath;
|
|
20
|
+
private readFile;
|
|
21
|
+
private writeFile;
|
|
22
|
+
addExecution(sourceId: string, execution: SourceJobExecution): void;
|
|
23
|
+
getExecutions(sourceId: string, jobId?: string): SourceJobExecution[];
|
|
24
|
+
clear(sourceId: string): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.SourceJobExecutionStore = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
class SourceJobExecutionStore {
|
|
10
|
+
constructor(appRootDir) {
|
|
11
|
+
this.maxExecutions = 100;
|
|
12
|
+
this.storageDir = path_1.default.join(appRootDir, 'storage', 'source-job-executions');
|
|
13
|
+
this.ensureStorageDir();
|
|
14
|
+
}
|
|
15
|
+
ensureStorageDir() {
|
|
16
|
+
if (!fs_1.default.existsSync(this.storageDir)) {
|
|
17
|
+
fs_1.default.mkdirSync(this.storageDir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
getFilePath(sourceId) {
|
|
21
|
+
return path_1.default.join(this.storageDir, `${sourceId}.json`);
|
|
22
|
+
}
|
|
23
|
+
readFile(sourceId) {
|
|
24
|
+
const filePath = this.getFilePath(sourceId);
|
|
25
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
26
|
+
return { sourceId, executions: [] };
|
|
27
|
+
}
|
|
28
|
+
const content = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
29
|
+
return JSON.parse(content);
|
|
30
|
+
}
|
|
31
|
+
writeFile(data) {
|
|
32
|
+
const filePath = this.getFilePath(data.sourceId);
|
|
33
|
+
fs_1.default.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
34
|
+
}
|
|
35
|
+
addExecution(sourceId, execution) {
|
|
36
|
+
const file = this.readFile(sourceId);
|
|
37
|
+
file.executions.push(execution);
|
|
38
|
+
// Prune to keep only last maxExecutions
|
|
39
|
+
if (file.executions.length > this.maxExecutions) {
|
|
40
|
+
file.executions = file.executions.slice(-this.maxExecutions);
|
|
41
|
+
}
|
|
42
|
+
this.writeFile(file);
|
|
43
|
+
}
|
|
44
|
+
getExecutions(sourceId, jobId) {
|
|
45
|
+
const file = this.readFile(sourceId);
|
|
46
|
+
let executions = file.executions;
|
|
47
|
+
if (jobId) {
|
|
48
|
+
executions = executions.filter(e => e.jobId === jobId);
|
|
49
|
+
}
|
|
50
|
+
// Return in reverse chronological order (most recent first)
|
|
51
|
+
return executions.reverse();
|
|
52
|
+
}
|
|
53
|
+
clear(sourceId) {
|
|
54
|
+
const filePath = this.getFilePath(sourceId);
|
|
55
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
56
|
+
fs_1.default.unlinkSync(filePath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.SourceJobExecutionStore = SourceJobExecutionStore;
|
|
61
|
+
//# sourceMappingURL=SourceJobExecutionStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceJobExecutionStore.js","sourceRoot":"","sources":["../../../../src/local_engine/storage/SourceJobExecutionStore.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAiBpB,MAAa,uBAAuB;IAIlC,YAAY,UAAkB;QAFtB,kBAAa,GAAW,GAAG,CAAC;QAGlC,IAAI,CAAC,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,uBAAuB,CAAC,CAAC;QAC5E,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACpC,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IA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IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAErC,IAAI,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAEjC,IAAI,KAAK,EAAE,CAAC;YACV,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QACzD,CAAC;QAED,4DAA4D;QAC5D,OAAO,UAAU,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAgB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF;AAjED,0DAiEC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StringSet - A Set implementation specifically for strings
|
|
3
|
+
* Extends the built-in Set class to provide type-safe operations for string values
|
|
4
|
+
*/
|
|
5
|
+
export declare class StringSet extends Set<string> {
|
|
6
|
+
constructor(values?: Iterable<string>);
|
|
7
|
+
/**
|
|
8
|
+
* Convert to JSON representation for serialization
|
|
9
|
+
*/
|
|
10
|
+
toJSON(): {
|
|
11
|
+
_type: string;
|
|
12
|
+
values: string[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Create StringSet from JSON representation
|
|
16
|
+
*/
|
|
17
|
+
static fromJSON(json: {
|
|
18
|
+
_type: string;
|
|
19
|
+
values: string[];
|
|
20
|
+
}): StringSet;
|
|
21
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringSet = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* StringSet - A Set implementation specifically for strings
|
|
6
|
+
* Extends the built-in Set class to provide type-safe operations for string values
|
|
7
|
+
*/
|
|
8
|
+
class StringSet extends Set {
|
|
9
|
+
constructor(values) {
|
|
10
|
+
super(values);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Convert to JSON representation for serialization
|
|
14
|
+
*/
|
|
15
|
+
toJSON() {
|
|
16
|
+
return {
|
|
17
|
+
_type: 'StringSet',
|
|
18
|
+
values: Array.from(this)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create StringSet from JSON representation
|
|
23
|
+
*/
|
|
24
|
+
static fromJSON(json) {
|
|
25
|
+
if (json._type !== 'StringSet') {
|
|
26
|
+
throw new Error('Invalid StringSet JSON representation');
|
|
27
|
+
}
|
|
28
|
+
return new StringSet(json.values);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.StringSet = StringSet;
|
|
32
|
+
//# sourceMappingURL=StringSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringSet.js","sourceRoot":"","sources":["../../../../src/local_engine/storage/StringSet.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,SAAU,SAAQ,GAAW;IACxC,YAAY,MAAyB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;SACzB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAyC;QACvD,IAAI,IAAI,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF;AAxBD,8BAwBC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for wrapper script communication
|
|
3
|
+
*/
|
|
4
|
+
export interface FunctionExecutionRequest {
|
|
5
|
+
functionId: string;
|
|
6
|
+
method: string;
|
|
7
|
+
fullpath: string;
|
|
8
|
+
path: string;
|
|
9
|
+
params: Record<string, any>;
|
|
10
|
+
headers: [string, string][];
|
|
11
|
+
body: any;
|
|
12
|
+
}
|
|
13
|
+
export interface FunctionExecutionResponse {
|
|
14
|
+
success: boolean;
|
|
15
|
+
status?: number;
|
|
16
|
+
headers?: [string, string][];
|
|
17
|
+
body?: any;
|
|
18
|
+
logs: string[];
|
|
19
|
+
error?: string;
|
|
20
|
+
stack?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface LifecycleExecutionRequest {
|
|
23
|
+
method: string;
|
|
24
|
+
params?: any;
|
|
25
|
+
scriptPath: string;
|
|
26
|
+
appDir: string;
|
|
27
|
+
}
|
|
28
|
+
export interface LifecycleExecutionResponse {
|
|
29
|
+
success: boolean;
|
|
30
|
+
logs: string[];
|
|
31
|
+
error?: string;
|
|
32
|
+
stack?: string;
|
|
33
|
+
result?: any;
|
|
34
|
+
}
|
|
35
|
+
export interface AppConfig {
|
|
36
|
+
manifest: any;
|
|
37
|
+
path: string;
|
|
38
|
+
isBuilt: boolean;
|
|
39
|
+
isValid: boolean;
|
|
40
|
+
baseUrl?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface WrapperInput {
|
|
43
|
+
appConfig: AppConfig;
|
|
44
|
+
appDir: string;
|
|
45
|
+
request: FunctionExecutionRequest | LifecycleExecutionRequest;
|
|
46
|
+
}
|
|
47
|
+
export interface WrapperOutput {
|
|
48
|
+
success: boolean;
|
|
49
|
+
result?: any;
|
|
50
|
+
error?: string;
|
|
51
|
+
stack?: string;
|
|
52
|
+
logs?: string[];
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/local_engine/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface SDKComponents {
|
|
2
|
+
App: any;
|
|
3
|
+
initializeStores: any;
|
|
4
|
+
LogLevel: any;
|
|
5
|
+
setNotifier: any;
|
|
6
|
+
initializeFunctionApi?: any;
|
|
7
|
+
Runtime: any;
|
|
8
|
+
Request: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Dynamically load the SDK from the app's node_modules
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadAppSDK(appPath: string): SDKComponents;
|
|
14
|
+
/**
|
|
15
|
+
* Find the correct function file path using entry_point from manifest
|
|
16
|
+
*/
|
|
17
|
+
export declare function findFunctionFile(appDir: string, functionId: string, manifest: any): string;
|
|
18
|
+
/**
|
|
19
|
+
* Find the Function class export from a module
|
|
20
|
+
*/
|
|
21
|
+
export declare function findFunctionClass(functionModule: any): any;
|
|
22
|
+
/**
|
|
23
|
+
* Find the Lifecycle class export from a module
|
|
24
|
+
*/
|
|
25
|
+
export declare function findLifecycleClass(lifecycleModule: any): any;
|
|
26
|
+
/**
|
|
27
|
+
* Parse command line arguments into structured input
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseWrapperArgs(): any;
|
|
30
|
+
/**
|
|
31
|
+
* Output result in the expected format for the parent process
|
|
32
|
+
*/
|
|
33
|
+
export declare function outputResult(result: any): void;
|
|
@@ -0,0 +1,143 @@
|
|
|
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.loadAppSDK = loadAppSDK;
|
|
7
|
+
exports.findFunctionFile = findFunctionFile;
|
|
8
|
+
exports.findFunctionClass = findFunctionClass;
|
|
9
|
+
exports.findLifecycleClass = findLifecycleClass;
|
|
10
|
+
exports.parseWrapperArgs = parseWrapperArgs;
|
|
11
|
+
exports.outputResult = outputResult;
|
|
12
|
+
/**
|
|
13
|
+
* Shared utilities for wrapper scripts
|
|
14
|
+
*/
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const LogManager_1 = require("../logging/LogManager");
|
|
18
|
+
const logManager = LogManager_1.LogManager.getInstance();
|
|
19
|
+
/**
|
|
20
|
+
* Dynamically load the SDK from the app's node_modules
|
|
21
|
+
*/
|
|
22
|
+
function loadAppSDK(appPath) {
|
|
23
|
+
const appSdkPath = path_1.default.join(appPath, 'node_modules', '@zaiusinc/app-sdk');
|
|
24
|
+
try {
|
|
25
|
+
const App = require(appSdkPath);
|
|
26
|
+
const { initializeStores, LogLevel, setNotifier, initializeFunctionApi, Runtime, Request } = require(appSdkPath);
|
|
27
|
+
return {
|
|
28
|
+
App,
|
|
29
|
+
initializeStores,
|
|
30
|
+
LogLevel,
|
|
31
|
+
setNotifier,
|
|
32
|
+
initializeFunctionApi,
|
|
33
|
+
Runtime,
|
|
34
|
+
Request
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new Error(`Failed to load SDK from ${appSdkPath}: ${error.message}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Find the correct function file path using entry_point from manifest
|
|
43
|
+
*/
|
|
44
|
+
function findFunctionFile(appDir, functionId, manifest) {
|
|
45
|
+
const functions = manifest.functions || {};
|
|
46
|
+
const functionDef = functions[functionId];
|
|
47
|
+
if (!functionDef) {
|
|
48
|
+
throw new Error(`Function '${functionId}' not found in app manifest`);
|
|
49
|
+
}
|
|
50
|
+
if (!functionDef.entry_point) {
|
|
51
|
+
throw new Error(`Function '${functionId}' does not have entry_point defined in manifest`);
|
|
52
|
+
}
|
|
53
|
+
const functionPath = path_1.default.join(appDir, "dist", "functions", `${functionDef.entry_point}.js`);
|
|
54
|
+
if (!fs_1.default.existsSync(functionPath)) {
|
|
55
|
+
throw new Error(`Function file not found: ${functionPath}. Make sure the app is built and the entry_point '${functionDef.entry_point}' matches the compiled file name.`);
|
|
56
|
+
}
|
|
57
|
+
return functionPath;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Find the Function class export from a module
|
|
61
|
+
*/
|
|
62
|
+
function findFunctionClass(functionModule) {
|
|
63
|
+
// Look for the Function class - it could be default export or named export
|
|
64
|
+
let FunctionClass = functionModule.default || functionModule[Object.keys(functionModule)[0]];
|
|
65
|
+
if (!FunctionClass) {
|
|
66
|
+
// Try to find a class that looks like a function class
|
|
67
|
+
for (const key in functionModule) {
|
|
68
|
+
if (typeof functionModule[key] === 'function') {
|
|
69
|
+
FunctionClass = functionModule[key];
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (!FunctionClass || typeof FunctionClass !== 'function') {
|
|
75
|
+
throw new Error(`Function class not found in module. Available exports: ${Object.keys(functionModule).join(', ')}`);
|
|
76
|
+
}
|
|
77
|
+
return FunctionClass;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Find the Lifecycle class export from a module
|
|
81
|
+
*/
|
|
82
|
+
function findLifecycleClass(lifecycleModule) {
|
|
83
|
+
// Look for the Lifecycle class - it could be default export or named export
|
|
84
|
+
let LifecycleClass = lifecycleModule.Lifecycle || lifecycleModule.default;
|
|
85
|
+
if (!LifecycleClass) {
|
|
86
|
+
// If not found, try to find any class that looks like a lifecycle class
|
|
87
|
+
for (const key in lifecycleModule) {
|
|
88
|
+
if (typeof lifecycleModule[key] === 'function' && key.toLowerCase().includes('lifecycle')) {
|
|
89
|
+
LifecycleClass = lifecycleModule[key];
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (!LifecycleClass || typeof LifecycleClass !== 'function') {
|
|
95
|
+
throw new Error(`Lifecycle class not found in module. Available exports: ${Object.keys(lifecycleModule).join(', ')}`);
|
|
96
|
+
}
|
|
97
|
+
return LifecycleClass;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parse command line arguments into structured input
|
|
101
|
+
*/
|
|
102
|
+
function parseWrapperArgs() {
|
|
103
|
+
const args = process.argv.slice(2);
|
|
104
|
+
if (args.length === 0) {
|
|
105
|
+
throw new Error('No input provided to wrapper script');
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
return JSON.parse(args[0]);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
throw new Error(`Failed to parse wrapper input: ${error}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Output result in the expected format for the parent process
|
|
116
|
+
*/
|
|
117
|
+
function outputResult(result) {
|
|
118
|
+
if (result.success) {
|
|
119
|
+
logManager.info(LogManager_1.LogSource.System, LogManager_1.LogCategory.AppRunner, 'SUCCESS', {
|
|
120
|
+
id: 'utils',
|
|
121
|
+
operation: 'output'
|
|
122
|
+
});
|
|
123
|
+
logManager.info(LogManager_1.LogSource.System, LogManager_1.LogCategory.AppRunner, `RESULT: ${JSON.stringify(result.result || null)}`, {
|
|
124
|
+
id: 'utils',
|
|
125
|
+
operation: 'output'
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
logManager.error(LogManager_1.LogSource.System, LogManager_1.LogCategory.AppRunner, `FAILED: ${result.error || 'Unknown error'}`, {
|
|
130
|
+
id: 'utils',
|
|
131
|
+
operation: 'output',
|
|
132
|
+
error: result.error
|
|
133
|
+
});
|
|
134
|
+
if (result.stack) {
|
|
135
|
+
logManager.error(LogManager_1.LogSource.System, LogManager_1.LogCategory.AppRunner, `STACK: ${result.stack}`, {
|
|
136
|
+
id: 'utils',
|
|
137
|
+
operation: 'output',
|
|
138
|
+
stack: result.stack
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+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