feat(server): enhance workflow and script handling with new features
- Added `workflowLastModifiedAt` function to retrieve the last modified timestamp of workflow YAML files. - Introduced `encodeBinaryForWire` and `reviveBinaryFromWire` functions for better handling of binary data in JSON. - Implemented `useDeleteKv` hook for deleting key-value pairs in the web API. - Enhanced `scriptsPluginFactory` to support dry-run evaluations with JSONata expressions. - Added `set-dry-run-smoke.js` test to validate dry-run functionality. - Updated profile configuration to include `overlayFromMerged` for better profile management. - Introduced try-session management in the web components to handle step execution states. - Improved various components to support new try-session features and maintain UI consistency. Co-authored-by: Nasyarobby Putra <nasyarobby@gmail.com>
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { jsonPreviewReplacer, summarizeBinary } from "../json-preview.js";
|
||||
import {
|
||||
encodeBinaryForWire,
|
||||
jsonPreviewReplacer,
|
||||
reviveBinaryFromWire,
|
||||
summarizeBinary,
|
||||
} from "../json-preview.js";
|
||||
import { serialize, toDisplayValue } from "../store.js";
|
||||
import { safeSerialize } from "../src/api/dry-run-logger.js";
|
||||
|
||||
@@ -53,4 +58,18 @@ if (typed.file.length !== png.length || typed.file.type !== "Buffer") {
|
||||
throw new Error(`Uint8Array: ${JSON.stringify(typed)}`);
|
||||
}
|
||||
|
||||
const wired = encodeBinaryForWire({ file: png, n: 1n });
|
||||
if (wired.n !== "1" || wired.file.encoding !== "base64" || typeof wired.file.data !== "string") {
|
||||
throw new Error(`encodeBinaryForWire: ${JSON.stringify(wired)}`);
|
||||
}
|
||||
const revived = reviveBinaryFromWire(JSON.parse(JSON.stringify(wired)));
|
||||
if (!Buffer.isBuffer(revived.file) || !revived.file.equals(png)) {
|
||||
throw new Error("reviveBinaryFromWire failed to restore bytes");
|
||||
}
|
||||
const previewOnly = { type: "Buffer", length: png.length, preview: "89", truncated: true };
|
||||
const left = reviveBinaryFromWire(previewOnly);
|
||||
if (Buffer.isBuffer(left)) {
|
||||
throw new Error("preview-only summary should not revive");
|
||||
}
|
||||
|
||||
console.log("json-preview-smoke: ok");
|
||||
|
||||
Reference in New Issue
Block a user