quidproquo-actionprocessor-node 0.1.3 → 0.1.5
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/lib/commonjs/actionProcessor/core/index.js +1 -0
- package/lib/commonjs/actionProcessor/core/index.js.map +1 -0
- package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +1 -0
- package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js.map +1 -0
- package/lib/commonjs/actionProcessor/core/inlineFunction/index.js +1 -0
- package/lib/commonjs/actionProcessor/core/inlineFunction/index.js.map +1 -0
- package/lib/commonjs/actionProcessor/core/stream/getStreamCloseActionProcessor.js +1 -0
- package/lib/commonjs/actionProcessor/core/stream/getStreamCloseActionProcessor.js.map +1 -0
- package/lib/commonjs/actionProcessor/core/stream/getStreamReadActionProcessor.js +1 -0
- package/lib/commonjs/actionProcessor/core/stream/getStreamReadActionProcessor.js.map +1 -0
- package/lib/commonjs/actionProcessor/core/stream/index.js +1 -0
- package/lib/commonjs/actionProcessor/core/stream/index.js.map +1 -0
- package/lib/commonjs/actionProcessor/index.js +1 -0
- package/lib/commonjs/actionProcessor/index.js.map +1 -0
- package/lib/commonjs/actionProcessor/webserver/index.js +1 -0
- package/lib/commonjs/actionProcessor/webserver/index.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileDeleteActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/index.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/index.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/secureUrlUtils.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/secureUrlUtils.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/types.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/types.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/utils.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/file/utils.js.map +1 -0
- package/lib/commonjs/dynamicActionProcessor/index.js +1 -0
- package/lib/commonjs/dynamicActionProcessor/index.js.map +1 -0
- package/lib/commonjs/index.d.ts +1 -0
- package/lib/commonjs/index.js +2 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/traceStoryExecution/controllerWorker.d.ts +11 -0
- package/lib/commonjs/traceStoryExecution/controllerWorker.js +409 -0
- package/lib/commonjs/traceStoryExecution/controllerWorker.js.map +1 -0
- package/lib/commonjs/traceStoryExecution/getSystemTraceStoryActionProcessor.d.ts +2 -0
- package/lib/commonjs/traceStoryExecution/getSystemTraceStoryActionProcessor.js +47 -0
- package/lib/commonjs/traceStoryExecution/getSystemTraceStoryActionProcessor.js.map +1 -0
- package/lib/commonjs/traceStoryExecution/index.d.ts +2 -0
- package/lib/commonjs/traceStoryExecution/index.js +19 -0
- package/lib/commonjs/traceStoryExecution/index.js.map +1 -0
- package/lib/commonjs/traceStoryExecution/resolveSourceMaps.d.ts +19 -0
- package/lib/commonjs/traceStoryExecution/resolveSourceMaps.js +159 -0
- package/lib/commonjs/traceStoryExecution/resolveSourceMaps.js.map +1 -0
- package/lib/commonjs/traceStoryExecution/traceStoryExecution.d.ts +17 -0
- package/lib/commonjs/traceStoryExecution/traceStoryExecution.js +140 -0
- package/lib/commonjs/traceStoryExecution/traceStoryExecution.js.map +1 -0
- package/lib/esm/actionProcessor/core/index.js +1 -0
- package/lib/esm/actionProcessor/core/index.js.map +1 -0
- package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +1 -0
- package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js.map +1 -0
- package/lib/esm/actionProcessor/core/inlineFunction/index.js +1 -0
- package/lib/esm/actionProcessor/core/inlineFunction/index.js.map +1 -0
- package/lib/esm/actionProcessor/core/stream/getStreamCloseActionProcessor.js +1 -0
- package/lib/esm/actionProcessor/core/stream/getStreamCloseActionProcessor.js.map +1 -0
- package/lib/esm/actionProcessor/core/stream/getStreamReadActionProcessor.js +1 -0
- package/lib/esm/actionProcessor/core/stream/getStreamReadActionProcessor.js.map +1 -0
- package/lib/esm/actionProcessor/core/stream/index.js +1 -0
- package/lib/esm/actionProcessor/core/stream/index.js.map +1 -0
- package/lib/esm/actionProcessor/index.js +1 -0
- package/lib/esm/actionProcessor/index.js.map +1 -0
- package/lib/esm/actionProcessor/webserver/index.js +1 -0
- package/lib/esm/actionProcessor/webserver/index.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/index.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/index.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/secureUrlUtils.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/secureUrlUtils.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/types.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/types.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/file/utils.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/utils.js.map +1 -0
- package/lib/esm/dynamicActionProcessor/index.js +1 -0
- package/lib/esm/dynamicActionProcessor/index.js.map +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/traceStoryExecution/controllerWorker.d.ts +11 -0
- package/lib/esm/traceStoryExecution/controllerWorker.js +406 -0
- package/lib/esm/traceStoryExecution/controllerWorker.js.map +1 -0
- package/lib/esm/traceStoryExecution/getSystemTraceStoryActionProcessor.d.ts +2 -0
- package/lib/esm/traceStoryExecution/getSystemTraceStoryActionProcessor.js +32 -0
- package/lib/esm/traceStoryExecution/getSystemTraceStoryActionProcessor.js.map +1 -0
- package/lib/esm/traceStoryExecution/index.d.ts +2 -0
- package/lib/esm/traceStoryExecution/index.js +3 -0
- package/lib/esm/traceStoryExecution/index.js.map +1 -0
- package/lib/esm/traceStoryExecution/resolveSourceMaps.d.ts +19 -0
- package/lib/esm/traceStoryExecution/resolveSourceMaps.js +118 -0
- package/lib/esm/traceStoryExecution/resolveSourceMaps.js.map +1 -0
- package/lib/esm/traceStoryExecution/traceStoryExecution.d.ts +17 -0
- package/lib/esm/traceStoryExecution/traceStoryExecution.js +126 -0
- package/lib/esm/traceStoryExecution/traceStoryExecution.js.map +1 -0
- package/package.json +7 -5
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Post-processing: map the controller's raw steps (generated script positions) back to
|
|
3
|
+
// original sources via the .map files sitting next to the traced scripts on disk —
|
|
4
|
+
// the same files the federated store syncs to /tmp alongside the code. When a map
|
|
5
|
+
// carries sourcesContent (the federated remote build embeds it), the original source
|
|
6
|
+
// text is embedded in the trace so viewers need no access to the repo.
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.resolveSourceMappedSteps = exports.filterOwnCodeLocations = void 0;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const url_1 = require("url");
|
|
45
|
+
const trace_mapping_1 = require("@jridgewell/trace-mapping");
|
|
46
|
+
const scriptUrlToPath = (scriptUrl) => (scriptUrl.startsWith('file://') ? (0, url_1.fileURLToPath)(scriptUrl) : scriptUrl);
|
|
47
|
+
// The LAST sourceMappingURL comment wins (bundles can contain earlier ones from inlined
|
|
48
|
+
// third-party code).
|
|
49
|
+
const findSourceMappingUrl = (scriptText) => {
|
|
50
|
+
const matches = scriptText.match(/\/\/[#@] sourceMappingURL=(\S+)/g);
|
|
51
|
+
if (!matches || matches.length === 0)
|
|
52
|
+
return null;
|
|
53
|
+
return matches[matches.length - 1].replace(/\/\/[#@] sourceMappingURL=/, '');
|
|
54
|
+
};
|
|
55
|
+
const loadTraceMap = (scriptPath) => {
|
|
56
|
+
try {
|
|
57
|
+
const scriptText = fs.readFileSync(scriptPath, 'utf8');
|
|
58
|
+
const sourceMappingUrl = findSourceMappingUrl(scriptText);
|
|
59
|
+
if (!sourceMappingUrl)
|
|
60
|
+
return null;
|
|
61
|
+
if (sourceMappingUrl.startsWith('data:')) {
|
|
62
|
+
const base64Match = sourceMappingUrl.match(/^data:application\/json[^,]*;base64,(.*)$/);
|
|
63
|
+
const json = base64Match
|
|
64
|
+
? Buffer.from(base64Match[1], 'base64').toString('utf8')
|
|
65
|
+
: decodeURIComponent(sourceMappingUrl.replace(/^data:[^,]*,/, ''));
|
|
66
|
+
return new trace_mapping_1.TraceMap(json);
|
|
67
|
+
}
|
|
68
|
+
const mapPath = path.resolve(path.dirname(scriptPath), sourceMappingUrl);
|
|
69
|
+
return new trace_mapping_1.TraceMap(fs.readFileSync(mapPath, 'utf8'));
|
|
70
|
+
}
|
|
71
|
+
catch (_a) {
|
|
72
|
+
// No map is a degraded trace, not a failure — generated positions still tell the story
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
// Which candidate breakpoint positions land in the service's OWN code — answers the
|
|
77
|
+
// controller worker's filterLocations request when onlyOwnCode tracing is on (the eval
|
|
78
|
+
// worker can't load trace-mapping itself). Positions mapping into node_modules
|
|
79
|
+
// (framework/deps) or not mapping at all (webpack runtime glue) are dropped. No map
|
|
80
|
+
// means the bundle can't be classified — everything stays traced.
|
|
81
|
+
const filterOwnCodeLocations = (scriptUrl, locations) => {
|
|
82
|
+
const traceMap = scriptUrl ? loadTraceMap(scriptUrlToPath(scriptUrl)) : null;
|
|
83
|
+
if (!traceMap) {
|
|
84
|
+
return locations;
|
|
85
|
+
}
|
|
86
|
+
return locations.filter((location) => {
|
|
87
|
+
var _a;
|
|
88
|
+
const original = (0, trace_mapping_1.originalPositionFor)(traceMap, { line: location.lineNumber + 1, column: (_a = location.columnNumber) !== null && _a !== void 0 ? _a : 0 });
|
|
89
|
+
return !!original.source && !original.source.includes('node_modules');
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
exports.filterOwnCodeLocations = filterOwnCodeLocations;
|
|
93
|
+
const resolveSourceMappedSteps = (rawSteps, scriptUrlsById) => {
|
|
94
|
+
const traceMapsByScriptId = new Map();
|
|
95
|
+
const sourceIndexByPath = new Map();
|
|
96
|
+
const sources = [];
|
|
97
|
+
const getTraceMap = (scriptId) => {
|
|
98
|
+
var _a;
|
|
99
|
+
if (!traceMapsByScriptId.has(scriptId)) {
|
|
100
|
+
const scriptUrl = scriptUrlsById[scriptId];
|
|
101
|
+
traceMapsByScriptId.set(scriptId, scriptUrl ? loadTraceMap(scriptUrlToPath(scriptUrl)) : null);
|
|
102
|
+
}
|
|
103
|
+
return (_a = traceMapsByScriptId.get(scriptId)) !== null && _a !== void 0 ? _a : null;
|
|
104
|
+
};
|
|
105
|
+
const getSourceIndex = (sourcePath, content) => {
|
|
106
|
+
const existing = sourceIndexByPath.get(sourcePath);
|
|
107
|
+
if (existing !== undefined)
|
|
108
|
+
return existing;
|
|
109
|
+
const index = sources.length;
|
|
110
|
+
sources.push(content !== undefined ? { path: sourcePath, content } : { path: sourcePath });
|
|
111
|
+
sourceIndexByPath.set(sourcePath, index);
|
|
112
|
+
return index;
|
|
113
|
+
};
|
|
114
|
+
// Unmapped fallback: the generated script itself becomes the source, content included
|
|
115
|
+
// so the viewer can still render something.
|
|
116
|
+
const getGeneratedSourceIndex = (scriptId) => {
|
|
117
|
+
const scriptUrl = scriptUrlsById[scriptId] || scriptId;
|
|
118
|
+
const existing = sourceIndexByPath.get(scriptUrl);
|
|
119
|
+
if (existing !== undefined)
|
|
120
|
+
return existing;
|
|
121
|
+
let content;
|
|
122
|
+
try {
|
|
123
|
+
content = fs.readFileSync(scriptUrlToPath(scriptUrl), 'utf8');
|
|
124
|
+
}
|
|
125
|
+
catch (_a) {
|
|
126
|
+
content = undefined;
|
|
127
|
+
}
|
|
128
|
+
return getSourceIndex(scriptUrl, content);
|
|
129
|
+
};
|
|
130
|
+
const steps = rawSteps.map((rawStep) => {
|
|
131
|
+
var _a, _b, _c;
|
|
132
|
+
const traceMap = getTraceMap(rawStep.scriptId);
|
|
133
|
+
if (traceMap) {
|
|
134
|
+
const original = (0, trace_mapping_1.originalPositionFor)(traceMap, { line: rawStep.line + 1, column: rawStep.column });
|
|
135
|
+
if (original.source) {
|
|
136
|
+
const content = (_a = (0, trace_mapping_1.sourceContentFor)(traceMap, original.source)) !== null && _a !== void 0 ? _a : undefined;
|
|
137
|
+
return {
|
|
138
|
+
sourceIndex: getSourceIndex(original.source, content),
|
|
139
|
+
line: (_b = original.line) !== null && _b !== void 0 ? _b : rawStep.line + 1,
|
|
140
|
+
column: (_c = original.column) !== null && _c !== void 0 ? _c : rawStep.column,
|
|
141
|
+
functionName: rawStep.functionName,
|
|
142
|
+
locals: rawStep.locals,
|
|
143
|
+
returnValue: rawStep.returnValue,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
sourceIndex: getGeneratedSourceIndex(rawStep.scriptId),
|
|
149
|
+
line: rawStep.line + 1,
|
|
150
|
+
column: rawStep.column,
|
|
151
|
+
functionName: rawStep.functionName,
|
|
152
|
+
locals: rawStep.locals,
|
|
153
|
+
returnValue: rawStep.returnValue,
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
return { sources, steps };
|
|
157
|
+
};
|
|
158
|
+
exports.resolveSourceMappedSteps = resolveSourceMappedSteps;
|
|
159
|
+
//# sourceMappingURL=resolveSourceMaps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSourceMaps.js","sourceRoot":"","sources":["../../../src/traceStoryExecution/resolveSourceMaps.ts"],"names":[],"mappings":";AAAA,uFAAuF;AACvF,mFAAmF;AACnF,kFAAkF;AAClF,qFAAqF;AACrF,uEAAuE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIvE,uCAAyB;AACzB,2CAA6B;AAC7B,6BAAoC;AACpC,6DAA4F;AAW5F,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAa,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAEhI,wFAAwF;AACxF,qBAAqB;AACrB,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAiB,EAAE;IACjE,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACrE,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,UAAkB,EAAmB,EAAE;IAC3D,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACvD,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,CAAC,gBAAgB;YAAE,OAAO,IAAI,CAAC;QAEnC,IAAI,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACzC,MAAM,WAAW,GAAG,gBAAgB,CAAC,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AAA,QAAQ,CAAC,IAAI,mCAAI,OAAO,CAAC,IAAI,GAAG,CAAC;oBACvC,MAAM,EAAE,MAAA,QAAQ,CAAC,MAAM,mCAAI,OAAO,CAAC,MAAM;oBACzC,YAAY,EAAE,OAAO,CAAC,YAAY;oBAClC,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,WAAW,EAAE,OAAO,CAAC,WAAW;iBACjC,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO;YACL,WAAW,EAAE,uBAAuB,CAAC,OAAO,CAAC,QAAQ,CAAC;YACtD,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,CAAC;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC;AApEW,QAAA,wBAAwB,4BAoEnC","sourcesContent":["// Post-processing: map the controller's raw steps (generated script positions) back to\n// original sources via the .map files sitting next to the traced scripts on disk —\n// the same files the federated store syncs to /tmp alongside the code. When a map\n// carries sourcesContent (the federated remote build embeds it), the original source\n// text is embedded in the trace so viewers need no access to the repo.\n\nimport { QpqExecutionTraceSource, QpqExecutionTraceStep, QpqExecutionTraceValue } from 'quidproquo-core';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\nimport { originalPositionFor, sourceContentFor, TraceMap } from '@jridgewell/trace-mapping';\n\ninterface RawTraceStep {\n scriptId: string;\n line: number; // 0-based (CDP)\n column: number;\n functionName: string;\n locals: Record<string, QpqExecutionTraceValue>;\n returnValue?: QpqExecutionTraceValue;\n}\n\nconst scriptUrlToPath = (scriptUrl: string): string => (scriptUrl.startsWith('file://') ? fileURLToPath(scriptUrl) : scriptUrl);\n\n// The LAST sourceMappingURL comment wins (bundles can contain earlier ones from inlined\n// third-party code).\nconst findSourceMappingUrl = (scriptText: string): string | null => {\n const matches = scriptText.match(/\\/\\/[#@] sourceMappingURL=(\\S+)/g);\n if (!matches || matches.length === 0) return null;\n return matches[matches.length - 1].replace(/\\/\\/[#@] sourceMappingURL=/, '');\n};\n\nconst loadTraceMap = (scriptPath: string): TraceMap | null => {\n try {\n const scriptText = fs.readFileSync(scriptPath, 'utf8');\n const sourceMappingUrl = findSourceMappingUrl(scriptText);\n if (!sourceMappingUrl) return null;\n\n if (sourceMappingUrl.startsWith('data:')) {\n const base64Match = sourceMappingUrl.match(/^data:application\\/json[^,]*;base64,(.*)$/);\n const json = base64Match\n ? Buffer.from(base64Match[1], 'base64').toString('utf8')\n : decodeURIComponent(sourceMappingUrl.replace(/^data:[^,]*,/, ''));\n return new TraceMap(json);\n }\n\n const mapPath = path.resolve(path.dirname(scriptPath), sourceMappingUrl);\n return new TraceMap(fs.readFileSync(mapPath, 'utf8'));\n } catch {\n // No map is a degraded trace, not a failure — generated positions still tell the story\n return null;\n }\n};\n\n// Which candidate breakpoint positions land in the service's OWN code — answers the\n// controller worker's filterLocations request when onlyOwnCode tracing is on (the eval\n// worker can't load trace-mapping itself). Positions mapping into node_modules\n// (framework/deps) or not mapping at all (webpack runtime glue) are dropped. No map\n// means the bundle can't be classified — everything stays traced.\nexport const filterOwnCodeLocations = <TLocation extends { lineNumber: number; columnNumber?: number }>(\n scriptUrl: string,\n locations: TLocation[],\n): TLocation[] => {\n const traceMap = scriptUrl ? loadTraceMap(scriptUrlToPath(scriptUrl)) : null;\n if (!traceMap) {\n return locations;\n }\n\n return locations.filter((location) => {\n const original = originalPositionFor(traceMap, { line: location.lineNumber + 1, column: location.columnNumber ?? 0 });\n return !!original.source && !original.source.includes('node_modules');\n });\n};\n\nexport interface ResolvedTraceSteps {\n sources: QpqExecutionTraceSource[];\n steps: QpqExecutionTraceStep[];\n}\n\nexport const resolveSourceMappedSteps = (rawSteps: RawTraceStep[], scriptUrlsById: Record<string, string>): ResolvedTraceSteps => {\n const traceMapsByScriptId = new Map<string, TraceMap | null>();\n const sourceIndexByPath = new Map<string, number>();\n const sources: QpqExecutionTraceSource[] = [];\n\n const getTraceMap = (scriptId: string): TraceMap | null => {\n if (!traceMapsByScriptId.has(scriptId)) {\n const scriptUrl = scriptUrlsById[scriptId];\n traceMapsByScriptId.set(scriptId, scriptUrl ? loadTraceMap(scriptUrlToPath(scriptUrl)) : null);\n }\n return traceMapsByScriptId.get(scriptId) ?? null;\n };\n\n const getSourceIndex = (sourcePath: string, content?: string): number => {\n const existing = sourceIndexByPath.get(sourcePath);\n if (existing !== undefined) return existing;\n\n const index = sources.length;\n sources.push(content !== undefined ? { path: sourcePath, content } : { path: sourcePath });\n sourceIndexByPath.set(sourcePath, index);\n return index;\n };\n\n // Unmapped fallback: the generated script itself becomes the source, content included\n // so the viewer can still render something.\n const getGeneratedSourceIndex = (scriptId: string): number => {\n const scriptUrl = scriptUrlsById[scriptId] || scriptId;\n const existing = sourceIndexByPath.get(scriptUrl);\n if (existing !== undefined) return existing;\n\n let content: string | undefined;\n try {\n content = fs.readFileSync(scriptUrlToPath(scriptUrl), 'utf8');\n } catch {\n content = undefined;\n }\n return getSourceIndex(scriptUrl, content);\n };\n\n const steps = rawSteps.map((rawStep): QpqExecutionTraceStep => {\n const traceMap = getTraceMap(rawStep.scriptId);\n\n if (traceMap) {\n const original = originalPositionFor(traceMap, { line: rawStep.line + 1, column: rawStep.column });\n if (original.source) {\n const content = sourceContentFor(traceMap, original.source) ?? undefined;\n return {\n sourceIndex: getSourceIndex(original.source, content),\n line: original.line ?? rawStep.line + 1,\n column: original.column ?? rawStep.column,\n functionName: rawStep.functionName,\n locals: rawStep.locals,\n returnValue: rawStep.returnValue,\n };\n }\n }\n\n return {\n sourceIndex: getGeneratedSourceIndex(rawStep.scriptId),\n line: rawStep.line + 1,\n column: rawStep.column,\n functionName: rawStep.functionName,\n locals: rawStep.locals,\n returnValue: rawStep.returnValue,\n };\n });\n\n return { sources, steps };\n};\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ActionProcessorList, QpqExecutionTrace, StoryResult } from 'quidproquo-core';
|
|
2
|
+
export interface TraceStoryExecutionOptions {
|
|
3
|
+
scriptPatterns?: string[];
|
|
4
|
+
onlyOwnCode?: boolean;
|
|
5
|
+
maxSteps?: number;
|
|
6
|
+
maxTraceMs?: number;
|
|
7
|
+
maxValueLength?: number;
|
|
8
|
+
maxProperties?: number;
|
|
9
|
+
maxValueDepth?: number;
|
|
10
|
+
maxSerializedLength?: number;
|
|
11
|
+
overrides?: ActionProcessorList;
|
|
12
|
+
}
|
|
13
|
+
export interface TraceStoryExecutionResult {
|
|
14
|
+
trace: QpqExecutionTrace;
|
|
15
|
+
replay: StoryResult<any>;
|
|
16
|
+
}
|
|
17
|
+
export declare const traceStoryExecution: (storyResult: StoryResult<any>, runtime: any, options?: TraceStoryExecutionOptions) => Promise<TraceStoryExecutionResult>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// traceStoryExecution — replay a StoryResult log against real story code and record a
|
|
3
|
+
// line-by-line execution trace: every statement executed, with local variable values.
|
|
4
|
+
//
|
|
5
|
+
// Wraps qpqExecuteLog (deterministic replay: every impure action is answered from the
|
|
6
|
+
// log's history), while a worker-thread debug controller (see controllerWorker.ts)
|
|
7
|
+
// drives the V8 inspector against this thread and captures each statement + locals.
|
|
8
|
+
// Because the replay is deterministic, the recorded trace carries the same information
|
|
9
|
+
// an interactive debug session would. See trace-replay-plan.md.
|
|
10
|
+
//
|
|
11
|
+
// The CALLER must run on the process MAIN THREAD (lambda handlers and the dev server
|
|
12
|
+
// do) — inspector.Session.connectToMainThread only targets the main thread.
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.traceStoryExecution = void 0;
|
|
24
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
25
|
+
const worker_threads_1 = require("worker_threads");
|
|
26
|
+
const controllerWorker_1 = require("./controllerWorker");
|
|
27
|
+
const resolveSourceMaps_1 = require("./resolveSourceMaps");
|
|
28
|
+
// Ready covers domain enable + breakpoint installation across every traced chunk —
|
|
29
|
+
// generous because the service function running this has minutes of budget, and an
|
|
30
|
+
// abort here wastes a replay that would have succeeded (instrumentMs in the trace stats
|
|
31
|
+
// shows the real cost).
|
|
32
|
+
const READY_TIMEOUT_MS = 120000;
|
|
33
|
+
const TRACE_TIMEOUT_MS = 60000;
|
|
34
|
+
// One trace at a time per process: the controller owns process-wide debugger state
|
|
35
|
+
// (breakpoints, pause handling), and the story function handoff is a global.
|
|
36
|
+
let traceInFlight = false;
|
|
37
|
+
const waitForControllerMessage = (controller, type, timeoutMs) => new Promise((resolve, reject) => {
|
|
38
|
+
const cleanUp = () => {
|
|
39
|
+
controller.off('message', onMessage);
|
|
40
|
+
controller.off('error', onError);
|
|
41
|
+
controller.off('exit', onExit);
|
|
42
|
+
clearTimeout(timeout);
|
|
43
|
+
};
|
|
44
|
+
const onMessage = (message) => {
|
|
45
|
+
if ((message === null || message === void 0 ? void 0 : message.type) === type) {
|
|
46
|
+
cleanUp();
|
|
47
|
+
resolve(message);
|
|
48
|
+
}
|
|
49
|
+
else if ((message === null || message === void 0 ? void 0 : message.type) === 'fatal') {
|
|
50
|
+
cleanUp();
|
|
51
|
+
reject(new Error(`trace controller failed: ${message.error}`));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const onError = (error) => {
|
|
55
|
+
cleanUp();
|
|
56
|
+
reject(error);
|
|
57
|
+
};
|
|
58
|
+
const onExit = (code) => {
|
|
59
|
+
cleanUp();
|
|
60
|
+
reject(new Error(`trace controller exited early with code [${code}]`));
|
|
61
|
+
};
|
|
62
|
+
const timeout = setTimeout(() => {
|
|
63
|
+
cleanUp();
|
|
64
|
+
reject(new Error(`timed out after ${timeoutMs}ms waiting for trace controller [${type}]`));
|
|
65
|
+
}, timeoutMs);
|
|
66
|
+
controller.on('message', onMessage);
|
|
67
|
+
controller.on('error', onError);
|
|
68
|
+
controller.on('exit', onExit);
|
|
69
|
+
});
|
|
70
|
+
const traceStoryExecution = (storyResult_1, runtime_1, ...args_1) => __awaiter(void 0, [storyResult_1, runtime_1, ...args_1], void 0, function* (storyResult, runtime, options = {}) {
|
|
71
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
72
|
+
if (traceInFlight) {
|
|
73
|
+
throw new Error('a story trace is already in progress in this process');
|
|
74
|
+
}
|
|
75
|
+
traceInFlight = true;
|
|
76
|
+
// The controller locates the story's script through this global ([[FunctionLocation]])
|
|
77
|
+
globalThis.__qpqTraceStoryFunction = runtime;
|
|
78
|
+
const workerData = {
|
|
79
|
+
scriptPatterns: (_a = options.scriptPatterns) !== null && _a !== void 0 ? _a : [],
|
|
80
|
+
onlyOwnCode: (_b = options.onlyOwnCode) !== null && _b !== void 0 ? _b : false,
|
|
81
|
+
maxSteps: (_c = options.maxSteps) !== null && _c !== void 0 ? _c : 20000,
|
|
82
|
+
maxTraceMs: (_d = options.maxTraceMs) !== null && _d !== void 0 ? _d : 120000,
|
|
83
|
+
maxValueLength: (_e = options.maxValueLength) !== null && _e !== void 0 ? _e : 1000,
|
|
84
|
+
maxProperties: (_f = options.maxProperties) !== null && _f !== void 0 ? _f : 32,
|
|
85
|
+
maxValueDepth: (_g = options.maxValueDepth) !== null && _g !== void 0 ? _g : 4,
|
|
86
|
+
maxSerializedLength: (_h = options.maxSerializedLength) !== null && _h !== void 0 ? _h : 30000,
|
|
87
|
+
};
|
|
88
|
+
// Lambdas ship as single-file webpack bundles, so the controller can't be a worker
|
|
89
|
+
// FILE on disk — it's serialized and run as an eval worker (see controllerWorker.ts).
|
|
90
|
+
const controller = new worker_threads_1.Worker(`(${controllerWorker_1.traceControllerWorkerMain.toString()})()`, {
|
|
91
|
+
eval: true,
|
|
92
|
+
workerData,
|
|
93
|
+
});
|
|
94
|
+
// onlyOwnCode: the worker can't load trace-mapping (eval worker, builtin requires
|
|
95
|
+
// only), so it round-trips candidate breakpoint locations here for source-map
|
|
96
|
+
// filtering. Attached before the ready-wait — instrumentation happens during init.
|
|
97
|
+
controller.on('message', (message) => {
|
|
98
|
+
if ((message === null || message === void 0 ? void 0 : message.type) === 'filterLocations') {
|
|
99
|
+
controller.postMessage({
|
|
100
|
+
type: 'filteredLocations',
|
|
101
|
+
requestId: message.requestId,
|
|
102
|
+
locations: (0, resolveSourceMaps_1.filterOwnCodeLocations)(message.scriptUrl, message.locations || []),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
try {
|
|
107
|
+
yield waitForControllerMessage(controller, 'ready', READY_TIMEOUT_MS);
|
|
108
|
+
const replayStartedAt = Date.now();
|
|
109
|
+
const replay = yield (0, quidproquo_core_1.qpqExecuteLog)(storyResult, runtime, options.overrides);
|
|
110
|
+
const replayMs = Date.now() - replayStartedAt;
|
|
111
|
+
const tracePromise = waitForControllerMessage(controller, 'trace', TRACE_TIMEOUT_MS);
|
|
112
|
+
controller.postMessage({ type: 'done' });
|
|
113
|
+
const rawTrace = yield tracePromise;
|
|
114
|
+
const { sources, steps } = (0, resolveSourceMaps_1.resolveSourceMappedSteps)(rawTrace.steps, rawTrace.scripts);
|
|
115
|
+
const trace = {
|
|
116
|
+
correlation: storyResult.correlation,
|
|
117
|
+
moduleName: storyResult.moduleName,
|
|
118
|
+
tracedAt: (0, quidproquo_core_1.getQpqIsoDateTimeFromDate)(new Date()),
|
|
119
|
+
truncated: rawTrace.stats.truncated,
|
|
120
|
+
sources,
|
|
121
|
+
steps,
|
|
122
|
+
stats: {
|
|
123
|
+
pauses: rawTrace.stats.pauses,
|
|
124
|
+
breakpoints: rawTrace.stats.breakpoints,
|
|
125
|
+
replayMs,
|
|
126
|
+
localsCaptureMs: rawTrace.stats.localsCaptureMs,
|
|
127
|
+
instrumentMs: rawTrace.stats.instrumentMs,
|
|
128
|
+
instrumentedScriptUrls: rawTrace.stats.instrumentedScriptUrls,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
return { trace, replay };
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
delete globalThis.__qpqTraceStoryFunction;
|
|
135
|
+
traceInFlight = false;
|
|
136
|
+
yield controller.terminate();
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
exports.traceStoryExecution = traceStoryExecution;
|
|
140
|
+
//# sourceMappingURL=traceStoryExecution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceStoryExecution.js","sourceRoot":"","sources":["../../../src/traceStoryExecution/traceStoryExecution.ts"],"names":[],"mappings":";AAAA,sFAAsF;AACtF,sFAAsF;AACtF,EAAE;AACF,sFAAsF;AACtF,mFAAmF;AACnF,oFAAoF;AACpF,uFAAuF;AACvF,gEAAgE;AAChE,EAAE;AACF,qFAAqF;AACrF,4EAA4E;;;;;;;;;;;;AAE5E,qDAAgI;AAEhI,mDAAwC;AAExC,yDAA0F;AAC1F,2DAAuF;AAsCvF,mFAAmF;AACnF,mFAAmF;AACnF,wFAAwF;AACxF,wBAAwB;AACxB,MAAM,gBAAgB,GAAG,MAAO,CAAC;AACjC,MAAM,gBAAgB,GAAG,KAAM,CAAC;AAEhC,mFAAmF;AACnF,6EAA6E;AAC7E,IAAI,aAAa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IAAA,2CAAyB,EAAC,IAAI,IAAI,EAAE,CAAC;YAC/C,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;YACnC,OAAO;YACP,KAAK;YACL,KAAK,EAAE;gBACL,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM;gBAC7B,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW;gBACvC,QAAQ;gBACR,eAAe,EAAE,QAAQ,CAAC,KAAK,CAAC,eAAe;gBAC/C,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,YAAY;gBACzC,sBAAsB,EAAE,QAAQ,CAAC,KAAK,CAAC,sBAAsB;aAC9D;SACF,CAAC;QAEF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,OAAQ,UAAkB,CAAC,uBAAuB,CAAC;QACnD,aAAa,GAAG,KAAK,CAAC;QACtB,MAAM,UAAU,CAAC,SAAS,EAAE,CAAC;IAC/B,CAAC;AACH,CAAC,CAAA,CAAC;AAhFW,QAAA,mBAAmB,uBAgF9B","sourcesContent":["// traceStoryExecution — replay a StoryResult log against real story code and record a\n// line-by-line execution trace: every statement executed, with local variable values.\n//\n// Wraps qpqExecuteLog (deterministic replay: every impure action is answered from the\n// log's history), while a worker-thread debug controller (see controllerWorker.ts)\n// drives the V8 inspector against this thread and captures each statement + locals.\n// Because the replay is deterministic, the recorded trace carries the same information\n// an interactive debug session would. See trace-replay-plan.md.\n//\n// The CALLER must run on the process MAIN THREAD (lambda handlers and the dev server\n// do) — inspector.Session.connectToMainThread only targets the main thread.\n\nimport { ActionProcessorList, getQpqIsoDateTimeFromDate, qpqExecuteLog, QpqExecutionTrace, StoryResult } from 'quidproquo-core';\n\nimport { Worker } from 'worker_threads';\n\nimport { TraceControllerWorkerData, traceControllerWorkerMain } from './controllerWorker';\nimport { filterOwnCodeLocations, resolveSourceMappedSteps } from './resolveSourceMaps';\n\nexport interface TraceStoryExecutionOptions {\n // Regex sources matched against script urls to trace IN ADDITION to the story\n // function's own script (auto-detected via [[FunctionLocation]]). Use for bundles\n // split across chunks, e.g. ['/tmp/qpq-federated-code/'].\n scriptPatterns?: string[];\n\n // Only break on statements whose source-mapped origin is the service's own code —\n // node_modules positions get no breakpoints, so the step/time budgets are spent\n // entirely on user statements. Scripts without a source map stay fully traced.\n onlyOwnCode?: boolean;\n\n // Step budget and wall-clock budget: past either, the replay finishes untraced and\n // the trace is marked truncated. The wall clock is what bounds total runtime — locals\n // capture makes per-step cost variable, so step count alone doesn't bound time.\n maxSteps?: number;\n maxTraceMs?: number;\n\n // Serialization caps for captured locals: string length, properties per object level,\n // object walk depth for the deep json capture, and total json size per value.\n maxValueLength?: number;\n maxProperties?: number;\n maxValueDepth?: number;\n maxSerializedLength?: number;\n\n // Passed through to qpqExecuteLog — lets specific action types execute for real\n // instead of being answered from the log.\n overrides?: ActionProcessorList;\n}\n\nexport interface TraceStoryExecutionResult {\n trace: QpqExecutionTrace;\n\n // The replay's own StoryResult (result/error of re-running the story)\n replay: StoryResult<any>;\n}\n\n// Ready covers domain enable + breakpoint installation across every traced chunk —\n// generous because the service function running this has minutes of budget, and an\n// abort here wastes a replay that would have succeeded (instrumentMs in the trace stats\n// shows the real cost).\nconst READY_TIMEOUT_MS = 120_000;\nconst TRACE_TIMEOUT_MS = 60_000;\n\n// One trace at a time per process: the controller owns process-wide debugger state\n// (breakpoints, pause handling), and the story function handoff is a global.\nlet traceInFlight = false;\n\nconst waitForControllerMessage = (controller: Worker, type: string, timeoutMs: number): Promise<any> =>\n new Promise((resolve, reject) => {\n const cleanUp = () => {\n controller.off('message', onMessage);\n controller.off('error', onError);\n controller.off('exit', onExit);\n clearTimeout(timeout);\n };\n const onMessage = (message: any) => {\n if (message?.type === type) {\n cleanUp();\n resolve(message);\n } else if (message?.type === 'fatal') {\n cleanUp();\n reject(new Error(`trace controller failed: ${message.error}`));\n }\n };\n const onError = (error: Error) => {\n cleanUp();\n reject(error);\n };\n const onExit = (code: number) => {\n cleanUp();\n reject(new Error(`trace controller exited early with code [${code}]`));\n };\n const timeout = setTimeout(() => {\n cleanUp();\n reject(new Error(`timed out after ${timeoutMs}ms waiting for trace controller [${type}]`));\n }, timeoutMs);\n\n controller.on('message', onMessage);\n controller.on('error', onError);\n controller.on('exit', onExit);\n });\n\nexport const traceStoryExecution = async (\n storyResult: StoryResult<any>,\n runtime: any,\n options: TraceStoryExecutionOptions = {},\n): Promise<TraceStoryExecutionResult> => {\n if (traceInFlight) {\n throw new Error('a story trace is already in progress in this process');\n }\n traceInFlight = true;\n\n // The controller locates the story's script through this global ([[FunctionLocation]])\n (globalThis as any).__qpqTraceStoryFunction = runtime;\n\n const workerData: TraceControllerWorkerData = {\n scriptPatterns: options.scriptPatterns ?? [],\n onlyOwnCode: options.onlyOwnCode ?? false,\n maxSteps: options.maxSteps ?? 20_000,\n maxTraceMs: options.maxTraceMs ?? 120_000,\n maxValueLength: options.maxValueLength ?? 1_000,\n maxProperties: options.maxProperties ?? 32,\n maxValueDepth: options.maxValueDepth ?? 4,\n maxSerializedLength: options.maxSerializedLength ?? 30_000,\n };\n\n // Lambdas ship as single-file webpack bundles, so the controller can't be a worker\n // FILE on disk — it's serialized and run as an eval worker (see controllerWorker.ts).\n const controller = new Worker(`(${traceControllerWorkerMain.toString()})()`, {\n eval: true,\n workerData,\n });\n\n // onlyOwnCode: the worker can't load trace-mapping (eval worker, builtin requires\n // only), so it round-trips candidate breakpoint locations here for source-map\n // filtering. Attached before the ready-wait — instrumentation happens during init.\n controller.on('message', (message: any) => {\n if (message?.type === 'filterLocations') {\n controller.postMessage({\n type: 'filteredLocations',\n requestId: message.requestId,\n locations: filterOwnCodeLocations(message.scriptUrl, message.locations || []),\n });\n }\n });\n\n try {\n await waitForControllerMessage(controller, 'ready', READY_TIMEOUT_MS);\n\n const replayStartedAt = Date.now();\n const replay = await qpqExecuteLog(storyResult, runtime, options.overrides);\n const replayMs = Date.now() - replayStartedAt;\n\n const tracePromise = waitForControllerMessage(controller, 'trace', TRACE_TIMEOUT_MS);\n controller.postMessage({ type: 'done' });\n const rawTrace = await tracePromise;\n\n const { sources, steps } = resolveSourceMappedSteps(rawTrace.steps, rawTrace.scripts);\n\n const trace: QpqExecutionTrace = {\n correlation: storyResult.correlation,\n moduleName: storyResult.moduleName,\n tracedAt: getQpqIsoDateTimeFromDate(new Date()),\n truncated: rawTrace.stats.truncated,\n sources,\n steps,\n stats: {\n pauses: rawTrace.stats.pauses,\n breakpoints: rawTrace.stats.breakpoints,\n replayMs,\n localsCaptureMs: rawTrace.stats.localsCaptureMs,\n instrumentMs: rawTrace.stats.instrumentMs,\n instrumentedScriptUrls: rawTrace.stats.instrumentedScriptUrls,\n },\n };\n\n return { trace, replay };\n } finally {\n delete (globalThis as any).__qpqTraceStoryFunction;\n traceInFlight = false;\n await controller.terminate();\n }\n};\n"]}
|
|
@@ -12,3 +12,4 @@ export const getCoreActionProcessor = async (qpqConfig, dynamicModuleLoader) =>
|
|
|
12
12
|
...(await getStreamActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
13
13
|
...(await getInlineFunctionActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
14
14
|
});
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/actionProcessor/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAGnG,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEpD,iFAAiF;AACjF,+DAA+D;AAC/D,4EAA4E;AAC5E,gEAAgE;AAChE,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AAEzB,MAAM,CAAC,MAAM,sBAAsB,GAAgC,KAAK,EACtE,SAAoB,EACpB,mBAAwC,EACV,EAAE,CAAC,CAAC;IAClC,GAAG,CAAC,MAAM,wBAAwB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACnE,GAAG,CAAC,MAAM,wBAAwB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACnE,GAAG,CAAC,MAAM,gCAAgC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CAC5E,CAAC,CAAC","sourcesContent":["import { getCoreActionProcessor as getJsCoreActionProcessor } from 'quidproquo-actionprocessor-js';\nimport { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nimport { getInlineFunctionActionProcessor } from './inlineFunction';\nimport { getStreamActionProcessor } from './stream';\n\n// The shared core processors (config, context, claudeAi, date, error, guid, log,\n// math, network, platform, system, customActions) are owned by\n// quidproquo-actionprocessor-js. Node builds on top of js and only adds the\n// processors that need a Node runtime (stream, inlineFunction).\nexport * from './inlineFunction';\nexport * from './stream';\n\nexport const getCoreActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getJsCoreActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getStreamActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getInlineFunctionActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js
CHANGED
|
@@ -30,3 +30,4 @@ const getProcessExecute = (qpqConfig) => {
|
|
|
30
30
|
export const getInlineFunctionExecuteActionProcessor = async (qpqConfig) => ({
|
|
31
31
|
[InlineFunctionActionType.Execute]: getProcessExecute(qpqConfig),
|
|
32
32
|
});
|
|
33
|
+
//# sourceMappingURL=getInlineFunctionExecuteActionProcessor.js.map
|
package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInlineFunctionExecuteActionProcessor.js","sourceRoot":"","sources":["../../../../../src/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EAEb,aAAa,EACb,wBAAwB,EAIxB,YAAY,EAEZ,cAAc,GAIf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAElD,MAAM,iBAAiB,GAAG,CAAO,SAAoB,EAA8C,EAAE;IACnG,MAAM,UAAU,GAAG,YAAY,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAEpE,OAAO,KAAK,EACV,OAA8C,EAC9C,OAAqB,EACrB,gBAAqC,EACrC,MAAiB,EACjB,aAAkC,EAClC,mBAAwC,EACxC,cAA8B,EAChB,EAAE;QAChB,MAAM,eAAe,GAAG,YAAY,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QACtE,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;QAE5F,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,iBAAiB,CAAC,aAAa,CAAC,QAAQ,EAAE,+BAA+B,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;QAC3G,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAEhE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,iBAAiB,CAAC,aAAa,CAAC,QAAQ,EAAE,gDAAgD,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC;QAC5H,CAAC;QAED,MAAM,YAAY,GAAG,aAAa,CAChC,SAAS,EACT;YACE,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,KAAK,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC;YAC/B,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;YAC9C,WAAW,EAAE,OAAO,CAAC,WAAW;SACjC,EACD,KAAK,IAAI,EAAE,CAAC,gBAAgB,EAC5B,UAAU,EACV,MAAM,EACN,GAAG,UAAU,KAAK,UAAU,EAAE,EAAE,EAChC,cAAc,CAAC,aAAa,EAC5B,mBAAmB,EACnB,cAAc,CAAC,OAAO,EACtB,EAAE,EACF,cAAc,CACf,CAAC;QAEF,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAEjE,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,iBAAiB,CACtB,WAAW,CAAC,KAAK,CAAC,SAAS,EAC3B,WAAW,CAAC,KAAK,CAAC,SAAS,EAC3B,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,QAAQ,WAAW,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CACrH,CAAC;QACJ,CAAC;QAED,OAAO,YAAY,CAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uCAAuC,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IACjJ,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC;CACjE,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n createRuntime,\n DynamicModuleLoader,\n ErrorTypeEnum,\n InlineFunctionActionType,\n InlineFunctionExecuteActionPayload,\n InlineFunctionExecuteActionProcessor,\n QPQConfig,\n qpqCoreUtils,\n QpqLogger,\n QpqRuntimeType,\n StorySession,\n StorySessionUpdater,\n StreamRegistry,\n} from 'quidproquo-core';\n\nimport { randomUUID } from 'crypto';\n\nconst getDateNow = () => new Date().toISOString();\n\nconst getProcessExecute = <R, T>(qpqConfig: QPQConfig): InlineFunctionExecuteActionProcessor<R, T> => {\n const moduleName = qpqCoreUtils.getApplicationModuleName(qpqConfig);\n\n return async (\n payload: InlineFunctionExecuteActionPayload<T>,\n session: StorySession,\n actionProcessors: ActionProcessorList,\n logger: QpqLogger,\n updateSession: StorySessionUpdater,\n dynamicModuleLoader: DynamicModuleLoader,\n streamRegistry: StreamRegistry,\n ): Promise<any> => {\n const inlineFunctions = qpqCoreUtils.getAllInlineFunctions(qpqConfig);\n const inlineFunction = inlineFunctions.find((f) => f.functionName === payload.functionName);\n\n if (!inlineFunction) {\n return actionResultError(ErrorTypeEnum.NotFound, `Inline function not found: [${payload.functionName}]`);\n }\n\n const story = await dynamicModuleLoader(inlineFunction.runtime);\n\n if (!story) {\n return actionResultError(ErrorTypeEnum.NotFound, `Unable to dynamically load inline function: [${payload.functionName}]`);\n }\n\n const resolveStory = createRuntime(\n qpqConfig,\n {\n context: session.context,\n localContext: session.localContext,\n depth: (session.depth || 0) + 1,\n decodedAccessToken: session.decodedAccessToken,\n correlation: session.correlation,\n },\n async () => actionProcessors,\n getDateNow,\n logger,\n `${moduleName}::${randomUUID()}`,\n QpqRuntimeType.EXECUTE_STORY,\n dynamicModuleLoader,\n inlineFunction.runtime,\n [],\n streamRegistry,\n );\n\n const storyResult = await resolveStory(story, [payload.payload]);\n\n if (storyResult.error) {\n return actionResultError(\n storyResult.error.errorType,\n storyResult.error.errorText,\n storyResult.error.errorStack ? `${payload.functionName} -> [${storyResult.error.errorStack}]` : payload.functionName,\n );\n }\n\n return actionResult<R>(storyResult.result);\n };\n};\n\nexport const getInlineFunctionExecuteActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [InlineFunctionActionType.Execute]: getProcessExecute(qpqConfig),\n});\n"]}
|
|
@@ -2,3 +2,4 @@ import { getInlineFunctionExecuteActionProcessor } from './getInlineFunctionExec
|
|
|
2
2
|
export const getInlineFunctionActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
3
3
|
...(await getInlineFunctionExecuteActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
4
4
|
});
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/actionProcessor/core/inlineFunction/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AAEpG,MAAM,CAAC,MAAM,gCAAgC,GAAgC,KAAK,EAChF,SAAoB,EACpB,mBAAwC,EACV,EAAE,CAAC,CAAC;IAClC,GAAG,CAAC,MAAM,uCAAuC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACnF,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nimport { getInlineFunctionExecuteActionProcessor } from './getInlineFunctionExecuteActionProcessor';\n\nexport const getInlineFunctionActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getInlineFunctionExecuteActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStreamCloseActionProcessor.js","sourceRoot":"","sources":["../../../../../src/actionProcessor/core/stream/getStreamCloseActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEZ,gBAAgB,GAEjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,qBAAqB,GAAG,CAAC,SAAoB,EAA8B,EAAE;IACjF,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,EAAE;QACnH,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IACvI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC;CAC3D,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n QPQConfig,\n StreamActionType,\n StreamCloseActionProcessor,\n} from 'quidproquo-core';\n\nconst getProcessStreamClose = (qpqConfig: QPQConfig): StreamCloseActionProcessor => {\n return async ({ streamId }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => {\n streamRegistry.close(streamId);\n return actionResult(undefined);\n };\n};\n\nexport const getStreamCloseActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [StreamActionType.Close]: getProcessStreamClose(qpqConfig),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStreamReadActionProcessor.js","sourceRoot":"","sources":["../../../../../src/actionProcessor/core/stream/getStreamReadActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEZ,gBAAgB,GAEjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAA6B,EAAE;IAC/E,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,EAAE;QAC3H,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC1D,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAgC,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IACtI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC;CACzD,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n QPQConfig,\n StreamActionType,\n StreamReadActionProcessor,\n} from 'quidproquo-core';\n\nconst getProcessStreamRead = (qpqConfig: QPQConfig): StreamReadActionProcessor => {\n return async ({ streamId, noWait }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => {\n const chunk = await streamRegistry.read(streamId, noWait);\n return actionResult(chunk);\n };\n};\n\nexport const getStreamReadActionProcessor: ActionProcessorListResolver = async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [StreamActionType.Read]: getProcessStreamRead(qpqConfig),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/actionProcessor/core/stream/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E,MAAM,CAAC,MAAM,wBAAwB,GAAgC,KAAK,EACxE,SAAoB,EACpB,mBAAwC,EACV,EAAE,CAAC,CAAC;IAClC,GAAG,CAAC,MAAM,6BAA6B,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACxE,GAAG,CAAC,MAAM,4BAA4B,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACxE,CAAC,CAAC","sourcesContent":["import { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\nimport { getStreamCloseActionProcessor } from './getStreamCloseActionProcessor';\nimport { getStreamReadActionProcessor } from './getStreamReadActionProcessor';\n\nexport const getStreamActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getStreamCloseActionProcessor(qpqConfig, dynamicModuleLoader)),\n ...(await getStreamReadActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actionProcessor/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC","sourcesContent":["export * from './core';\nexport * from './webserver';\n"]}
|
|
@@ -4,3 +4,4 @@ import { getWebserverActionProcessor as getJsWebserverActionProcessor } from 'qu
|
|
|
4
4
|
export const getWebserverActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
5
5
|
...(await getJsWebserverActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
6
6
|
});
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/actionProcessor/webserver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,IAAI,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAG7G,yFAAyF;AACzF,qFAAqF;AACrF,MAAM,CAAC,MAAM,2BAA2B,GAAgC,KAAK,EAC3E,SAAoB,EACpB,mBAAwC,EACV,EAAE,CAAC,CAAC;IAClC,GAAG,CAAC,MAAM,6BAA6B,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;CACzE,CAAC,CAAC","sourcesContent":["import { getWebserverActionProcessor as getJsWebserverActionProcessor } from 'quidproquo-actionprocessor-js';\nimport { ActionProcessorList, ActionProcessorListResolver, DynamicModuleLoader, QPQConfig } from 'quidproquo-core';\n\n// The shared webserver processors (dns, ...) are owned by quidproquo-actionprocessor-js.\n// Node builds on top of js; it currently adds no node-specific webserver processors.\nexport const getWebserverActionProcessor: ActionProcessorListResolver = async (\n qpqConfig: QPQConfig,\n dynamicModuleLoader: DynamicModuleLoader,\n): Promise<ActionProcessorList> => ({\n ...(await getJsWebserverActionProcessor(qpqConfig, dynamicModuleLoader)),\n});\n"]}
|
|
@@ -34,3 +34,4 @@ const getProcessFileDelete = (qpqConfig, config) => {
|
|
|
34
34
|
export const getFileDeleteActionProcessor = (config) => async (qpqConfig) => ({
|
|
35
35
|
[FileActionType.Delete]: getProcessFileDelete(qpqConfig, config),
|
|
36
36
|
});
|
|
37
|
+
//# sourceMappingURL=getFileDeleteActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileDeleteActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileDeleteActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,cAAc,EAEd,uBAAuB,GAExB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAA6B,EAAE;IAC1G,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;QACpC,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,MAAM,MAAM,GAAuC,EAAE,CAAC;QAEtD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,e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AC,CAAC;IAC7D,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC;CACjE,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileDeleteActionProcessor,\n FileDeleteErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileDelete = (qpqConfig: QPQConfig, config: FileStorageConfig): FileDeleteActionProcessor => {\n return async ({ drive, filepaths }) => {\n const deletedFiles: string[] = [];\n const errors: { filepath: string; error: any }[] = [];\n\n for (const filepath of filepaths) {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n\n await fs.unlink(fullPath);\n deletedFiles.push(filepath);\n } catch (error: any) {\n // If file doesn't exist, consider it successfully deleted\n if (error.code === 'ENOENT') {\n deletedFiles.push(filepath);\n } else {\n errors.push({ filepath, error });\n }\n }\n }\n\n if (errors.length > 0 && deletedFiles.length === 0) {\n // EACCES maps to the same typed error the S3 processor returns for AccessDenied\n if (errors.some(({ error }) => error.code === 'EACCES')) {\n return actionResultError(FileDeleteErrorTypeEnum.AccessDenied, 'Access denied deleting files');\n }\n return actionResultError(\n ErrorTypeEnum.GenericError,\n `Failed to delete files: ${errors.map(({ filepath, error }) => `Failed to delete ${filepath}: ${error.message}`).join(', ')}`,\n );\n }\n\n return actionResult(deletedFiles);\n };\n};\n\nexport const getFileDeleteActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.Delete]: getProcessFileDelete(qpqConfig, config),\n });\n"]}
|
|
@@ -28,3 +28,4 @@ const getProcessFileExists = (qpqConfig, config) => {
|
|
|
28
28
|
export const getFileExistsActionProcessor = (config) => async (qpqConfig) => ({
|
|
29
29
|
[FileActionType.Exists]: getProcessFileExists(qpqConfig, config),
|
|
30
30
|
});
|
|
31
|
+
//# sourceMappingURL=getFileExistsActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileExistsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileExistsActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,cAAc,EAEd,uBAAuB,GAExB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAA6B,EAAE;IAC1G,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QACnC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YAErE,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC1B,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,wEAAwE;gBACxE,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5B,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;gBACD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC5B,OAAO,iBAAiB,CAAC,uBAAuB,CAAC,YAAY,EAAE,0CAA0C,QAAQ,EAAE,CAAC,CAAC;gBACvH,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,iBAAiB,CAAC,aAAa,CAAC,YAAY,EAAE,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1G,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GACvC,CAAC,MAAyB,EAA+B,EAAE,CAC3D,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7D,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC;CACjE,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileExistsActionProcessor,\n FileExistsErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileExists = (qpqConfig: QPQConfig, config: FileStorageConfig): FileExistsActionProcessor => {\n return async ({ drive, filepath }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n\n try {\n await fs.access(fullPath);\n return actionResult(true);\n } catch (error: any) {\n // Missing file is a definitive false; permission problems must surface.\n if (error.code === 'ENOENT') {\n return actionResult(false);\n }\n if (error.code === 'EACCES') {\n return actionResultError(FileExistsErrorTypeEnum.AccessDenied, `Access denied checking file existence: ${filepath}`);\n }\n throw error;\n }\n } catch (error: any) {\n return actionResultError(ErrorTypeEnum.GenericError, `Error checking file existence: ${error.message}`);\n }\n };\n};\n\nexport const getFileExistsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.Exists]: getProcessFileExists(qpqConfig, config),\n });\n"]}
|
package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js
CHANGED
|
@@ -23,3 +23,4 @@ const getProcessFileGenerateTemporarySecureUrl = (qpqConfig, config) => {
|
|
|
23
23
|
export const getFileGenerateTemporarySecureUrlActionProcessor = (config) => async (qpqConfig) => ({
|
|
24
24
|
[FileActionType.GenerateTemporarySecureUrl]: getProcessFileGenerateTemporarySecureUrl(qpqConfig, config),
|
|
25
25
|
});
|
|
26
|
+
//# sourceMappingURL=getFileGenerateTemporarySecureUrlActionProcessor.js.map
|
package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileGenerateTemporarySecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,cAAc,GAGf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,wCAAwC,GAAG,CAAC,SAAoB,EAAE,MAAyB,EAAiD,EAAE;IAClJ,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,EAAE;QACjD,IAAI,CAAC;YACH,8BAA8B;YAC9B,MAAM,KAAK,GAAG,oBAAoB,CAChC;gBACE,YAAY,EAAE,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;gBACjE,SAAS,EAAE,UAAU;gBACrB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY;aACrC,EACD,MAAM,CAAC,eAAe,CACvB,CAAC;YAEF,uBAAuB;YACvB,MAAM,OAAO,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,GAAG,OAAO,0BAA0B,KAAK,EAAE,CAAC;YAExD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,iBAAiB,CAAC,aAAa,CAAC,YAAY,EAAE,4CAA4C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gDAAgD,GAC3D,CAAC,MAAyB,EAA+B,EAAE,CAC3D,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7D,CAAC,cAAc,CAAC,0BAA0B,CAAC,EAAE,wCAAwC,CAAC,SAAS,EAAE,MAAM,CAAC;CACzG,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileGenerateTemporarySecureUrlActionProcessor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { createSecureUrlToken, getSecureUrlBaseUrl } from './secureUrlUtils';\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileGenerateTemporarySecureUrl = (qpqConfig: QPQConfig, config: FileStorageConfig): FileGenerateTemporarySecureUrlActionProcessor => {\n return async ({ drive, filepath, expirationMs }) => {\n try {\n // Create a token for download\n const token = createSecureUrlToken(\n {\n fullFilepath: resolveFilePath(config, qpqConfig, drive, filepath),\n operation: 'download',\n expiresAt: Date.now() + expirationMs,\n },\n config.secureUrlSecret,\n );\n\n // Build the secure URL\n const baseUrl = getSecureUrlBaseUrl(config);\n const url = `${baseUrl}/secure-download?token=${token}`;\n\n return actionResult(url);\n } catch (error: any) {\n return actionResultError(ErrorTypeEnum.GenericError, `Unable to generate temporary secure URL: ${error.message}`);\n }\n };\n};\n\nexport const getFileGenerateTemporarySecureUrlActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporarySecureUrl]: getProcessFileGenerateTemporarySecureUrl(qpqConfig, config),\n });\n"]}
|
|
@@ -26,3 +26,4 @@ const getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig, config) => {
|
|
|
26
26
|
export const getFileGenerateTemporaryUploadSecureUrlActionProcessor = (config) => async (qpqConfig) => ({
|
|
27
27
|
[FileActionType.GenerateTemporaryUploadSecureUrl]: getProcessFileGenerateTemporaryUploadSecureUrl(qpqConfig, config),
|
|
28
28
|
});
|
|
29
|
+
//# sourceMappingURL=getFileGenerateTemporaryUploadSecureUrlActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileGenerateTemporaryUploadSecureUrlActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,cAAc,GAGf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,8CAA8C,GAAG,CACrD,SAAoB,EACpB,MAAyB,EAC4B,EAAE;IACvD,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,EAAE;QAC9D,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC;YAE5C,4BAA4B;YAC5B,MAAM,KAAK,GAAG,oBAAoB,CAChC;gBACE,YAAY,EAAE,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC;gBACjE,SAAS,EAAE,QAAQ;gBACnB,SAAS;gBACT,WAAW;aACZ,EACD,MAAM,CAAC,eAAe,CACvB,CAAC;YAEF,uBAAuB;YACvB,MAAM,OAAO,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,GAAG,GAAG,GAAG,OAAO,wBAAwB,KAAK,EAAE,CAAC;YAEtD,OAAO,CAAC,GAAG,CAAC,4BAA4B,QAAQ,aAAa,KAAK,gBAAgB,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAEvH,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,iBAAiB,CAAC,aAAa,CAAC,YAAY,EAAE,mDAAmD,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3H,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sDAAsD,GACjE,CAAC,MAAyB,EAA+B,EAAE,CAC3D,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7D,CAAC,cAAc,CAAC,gCAAgC,CAAC,EAAE,8CAA8C,CAAC,SAAS,EAAE,MAAM,CAAC;CACrH,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n ErrorTypeEnum,\n FileActionType,\n FileGenerateTemporaryUploadSecureUrlActionProcessor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { createSecureUrlToken, getSecureUrlBaseUrl } from './secureUrlUtils';\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileGenerateTemporaryUploadSecureUrl = (\n qpqConfig: QPQConfig,\n config: FileStorageConfig,\n): FileGenerateTemporaryUploadSecureUrlActionProcessor => {\n return async ({ drive, filepath, expirationMs, contentType }) => {\n try {\n const expiresAt = Date.now() + expirationMs;\n\n // Create a token for upload\n const token = createSecureUrlToken(\n {\n fullFilepath: resolveFilePath(config, qpqConfig, drive, filepath),\n operation: 'upload',\n expiresAt,\n contentType,\n },\n config.secureUrlSecret,\n );\n\n // Build the secure URL\n const baseUrl = getSecureUrlBaseUrl(config);\n const url = `${baseUrl}/secure-upload?token=${token}`;\n\n console.log(`Generated upload URL for ${filepath} in drive ${drive}, expires at ${new Date(expiresAt).toISOString()}`);\n\n return actionResult(url);\n } catch (error: any) {\n return actionResultError(ErrorTypeEnum.GenericError, `Unable to generate temporary upload secure URL: ${error.message}`);\n }\n };\n};\n\nexport const getFileGenerateTemporaryUploadSecureUrlActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.GenerateTemporaryUploadSecureUrl]: getProcessFileGenerateTemporaryUploadSecureUrl(qpqConfig, config),\n });\n"]}
|
|
@@ -8,3 +8,4 @@ const getProcessFileIsColdStorage = (config) => (qpqConfig) => {
|
|
|
8
8
|
export const getFileIsColdStorageActionProcessor = (config) => async (qpqConfig) => ({
|
|
9
9
|
[FileActionType.IsColdStorage]: getProcessFileIsColdStorage(config)(qpqConfig),
|
|
10
10
|
});
|
|
11
|
+
//# sourceMappingURL=getFileIsColdStorageActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileIsColdStorageActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,cAAc,GAGf,MAAM,iBAAiB,CAAC;AAIzB,MAAM,2BAA2B,GAC/B,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAAoC,EAAE;IACzD,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QACnC,kEAAkE;QAClE,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,mCAAmC,GAC9C,CAAC,MAAyB,EAA+B,EAAE,CAC3D,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7D,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;CAC/E,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n FileActionType,\n FileIsColdStorageActionProcessor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport { FileStorageConfig } from './types';\n\nconst getProcessFileIsColdStorage =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileIsColdStorageActionProcessor => {\n return async ({ drive, filepath }) => {\n // Local filesystem doesn't have cold storage, always return false\n return actionResult(false);\n };\n };\n\nexport const getFileIsColdStorageActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.IsColdStorage]: getProcessFileIsColdStorage(config)(qpqConfig),\n });\n"]}
|
|
@@ -45,3 +45,4 @@ const getProcessFileListDirectory = (config) => (qpqConfig) => {
|
|
|
45
45
|
export const getFileListDirectoryActionProcessor = (config) => async (qpqConfig) => ({
|
|
46
46
|
[FileActionType.ListDirectory]: getProcessFileListDirectory(config)(qpqConfig),
|
|
47
47
|
});
|
|
48
|
+
//# sourceMappingURL=getFileListDirectoryActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileListDirectoryActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAEhC,cAAc,EAGd,8BAA8B,GAE/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,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,CAAC,CAAC;YAE5D,MAAM,MAAM,GAAkB;gBAC5B,SAAS,EAAE,cAAc;aAC1B,CAAC;YAEF,yCAAyC;YACzC,IAAI,QAAQ,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC/B,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACzC,CAAC;YAED,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,iBAAiB,EAAE,wBAAwB,UAAU,EAAE,CAAC,EAAE,eAAe;gBACxI,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,aAAa,EAAE,4BAA4B,UAAU,EAAE,CAAC,EAAE,eAAe;gBACzI,MAAM,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,YAAY,EAAE,oCAAoC,UAAU,EAAE,CAAC,EAAE,eAAe;aAChJ,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,mCAAmC,GAC9C,CAAC,MAAyB,EAA+B,EAAE,CAC3D,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7D,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;CAC/E,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n DirectoryList,\n FileActionType,\n FileInfo,\n FileListDirectoryActionProcessor,\n FileListDirectoryErrorTypeEnum,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileListDirectory =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileListDirectoryActionProcessor => {\n return async ({ drive, folderPath, maxFiles, pageToken }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, folderPath || '');\n\n // Read all entries in the directory\n const entries = await fs.readdir(fullPath, { withFileTypes: true });\n\n // Build file info list\n const allFiles: FileInfo[] = [];\n for (const entry of entries) {\n allFiles.push({\n filepath: path.join(folderPath || '', entry.name),\n drive: drive,\n isDir: entry.isDirectory(),\n hashMd5: undefined,\n });\n }\n\n // Sort by filepath for consistent pagination\n allFiles.sort((a, b) => a.filepath.localeCompare(b.filepath));\n\n // Handle pagination\n const startIndex = pageToken ? parseInt(pageToken, 10) : 0;\n const endIndex = Math.min(startIndex + maxFiles, allFiles.length);\n const paginatedFiles = allFiles.slice(startIndex, endIndex);\n\n const result: DirectoryList = {\n fileInfos: paginatedFiles,\n };\n\n // Add page token if there are more files\n if (endIndex < allFiles.length) {\n result.pageToken = endIndex.toString();\n }\n\n return actionResult(result);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n ENOENT: () => actionResultError(FileListDirectoryErrorTypeEnum.DirectoryNotFound, `Directory not found: ${folderPath}`), // node fs code\n ENOTDIR: () => actionResultError(FileListDirectoryErrorTypeEnum.NotADirectory, `Path is not a directory: ${folderPath}`), // node fs code\n EACCES: () => actionResultError(FileListDirectoryErrorTypeEnum.AccessDenied, `Access denied listing directory: ${folderPath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileListDirectoryActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ListDirectory]: getProcessFileListDirectory(config)(qpqConfig),\n });\n"]}
|
|
@@ -25,3 +25,4 @@ const getProcessFileReadBinaryContents = (config) => (qpqConfig) => {
|
|
|
25
25
|
export const getFileReadBinaryContentsActionProcessor = (config) => async (qpqConfig) => ({
|
|
26
26
|
[FileActionType.ReadBinaryContents]: getProcessFileReadBinaryContents(config)(qpqConfig),
|
|
27
27
|
});
|
|
28
|
+
//# sourceMappingURL=getFileReadBinaryContentsActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileReadBinaryContentsActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,cAAc,EAEd,mCAAmC,GAGpC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,gCAAgC,GACpC,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAAyC,EAAE;IAC9D,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QACnC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrE,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAE3C,kCAAkC;YAClC,MAAM,UAAU,GAAkB;gBAChC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACrC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACjC,QAAQ,EAAE,0BAA0B,EAAE,oCAAoC;aAC3E,CAAC;YAEF,OAAO,YAAY,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,YAAY,EAAE,mBAAmB,QAAQ,EAAE,CAAC,EAAE,eAAe;aAClI,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,wCAAwC,GACnD,CAAC,MAAyB,EAA+B,EAAE,CAC3D,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7D,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAAE,gCAAgC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;CACzF,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n FileActionType,\n FileReadBinaryContentsActionProcessor,\n FileReadBinaryContentsErrorTypeEnum,\n QPQBinaryData,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileReadBinaryContents =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileReadBinaryContentsActionProcessor => {\n return async ({ drive, filepath }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n const buffer = await fs.readFile(fullPath);\n\n // Convert Buffer to QPQBinaryData\n const binaryData: QPQBinaryData = {\n base64Data: buffer.toString('base64'),\n filename: path.basename(filepath),\n mimetype: 'application/octet-stream', // Default mimetype for binary files\n };\n\n return actionResult(binaryData);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n ENOENT: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code\n });\n }\n };\n };\n\nexport const getFileReadBinaryContentsActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadBinaryContents]: getProcessFileReadBinaryContents(config)(qpqConfig),\n });\n"]}
|
|
@@ -20,3 +20,4 @@ const getProcessFileReadObjectJson = (config) => (qpqConfig) => {
|
|
|
20
20
|
export const getFileReadObjectJsonActionProcessor = (config) => async (qpqConfig) => ({
|
|
21
21
|
[FileActionType.ReadObjectJson]: getProcessFileReadObjectJson(config)(qpqConfig),
|
|
22
22
|
});
|
|
23
|
+
//# sourceMappingURL=getFileReadObjectJsonActionProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFileReadObjectJsonActionProcessor.js","sourceRoot":"","sources":["../../../../src/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,iBAAiB,EACjB,gCAAgC,EAChC,aAAa,EACb,cAAc,GAGf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,4BAA4B,GAChC,CAAC,MAAyB,EAAE,EAAE,CAC9B,CAAC,SAAoB,EAA0C,EAAE;IAC/D,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QACnC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrE,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACvC,OAAO,YAAY,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,gCAAgC,CAAC,KAAK,EAAE;gBAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,QAAQ,EAAE,mBAAmB,QAAQ,EAAE,CAAC,EAAE,eAAe;gBACvG,WAAW,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,YAAY,EAAE,yBAAyB,QAAQ,EAAE,CAAC,EAAE,qBAAqB;aAC7H,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,oCAAoC,GAC/C,CAAC,MAAyB,EAA+B,EAAE,CAC3D,KAAK,EAAE,SAAoB,EAAgC,EAAE,CAAC,CAAC;IAC7D,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC;CACjF,CAAC,CAAC","sourcesContent":["import {\n ActionProcessorList,\n ActionProcessorListResolver,\n actionResult,\n actionResultError,\n actionResultErrorFromCaughtError,\n ErrorTypeEnum,\n FileActionType,\n FileReadObjectJsonActionProcessor,\n QPQConfig,\n} from 'quidproquo-core';\n\nimport * as fs from 'fs/promises';\n\nimport { FileStorageConfig } from './types';\nimport { resolveFilePath } from './utils';\n\nconst getProcessFileReadObjectJson =\n (config: FileStorageConfig) =>\n (qpqConfig: QPQConfig): FileReadObjectJsonActionProcessor<any> => {\n return async ({ drive, filepath }) => {\n try {\n const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);\n const content = await fs.readFile(fullPath, 'utf8');\n const jsonObject = JSON.parse(content);\n return actionResult(jsonObject);\n } catch (error: unknown) {\n return actionResultErrorFromCaughtError(error, {\n ENOENT: () => actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`), // node fs code\n SyntaxError: () => actionResultError(ErrorTypeEnum.GenericError, `Invalid JSON in file: ${filepath}`), // JSON.parse failure\n });\n }\n };\n };\n\nexport const getFileReadObjectJsonActionProcessor =\n (config: FileStorageConfig): ActionProcessorListResolver =>\n async (qpqConfig: QPQConfig): Promise<ActionProcessorList> => ({\n [FileActionType.ReadObjectJson]: getProcessFileReadObjectJson(config)(qpqConfig),\n });\n"]}
|