openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
60 lines (59 loc) • 3.43 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { t as normalizeClawHubSha256Hex } from "./clawhub-integrity-DTNmm7ZL.mjs";
//#region src/plugins/clawhub-install-records.ts
function normalizeClawHubClawPackInstallFields(e) {
const t = e && "kind" in e && normalizeOptionalString(e.kind) === "npm-pack";
const n = e && "available" in e && e.available;
if (!t && !n) return {};
const r = typeof e.sha256 === "string" ? normalizeClawHubSha256Hex(e.sha256) : null;
const i = "manifestSha256" in e && typeof e.manifestSha256 === "string" ? normalizeClawHubSha256Hex(e.manifestSha256) : null;
const a = "specVersion" in e && typeof e.specVersion === "number" && Number.isSafeInteger(e.specVersion) && e.specVersion >= 0 ? e.specVersion : void 0;
const o = typeof e.size === "number" && Number.isSafeInteger(e.size) && e.size >= 0 ? e.size : void 0;
const s = normalizeOptionalString(e.npmIntegrity);
const c = normalizeOptionalString(e.npmShasum);
const l = normalizeOptionalString(e.npmTarballName);
return {
artifactKind: "npm-pack",
artifactFormat: "tgz",
...s ? { npmIntegrity: s } : {},
...c ? { npmShasum: c } : {},
...l ? { npmTarballName: l } : {},
...r ? { clawpackSha256: r } : {},
...a !== void 0 ? { clawpackSpecVersion: a } : {},
...i ? { clawpackManifestSha256: i } : {},
...o !== void 0 ? { clawpackSize: o } : {}
};
}
/** Builds plugin install record fields from resolved ClawHub package metadata. */
function buildClawHubPluginInstallRecordFields(e) {
return {
source: "clawhub",
clawhubUrl: e.clawhubUrl,
clawhubPackage: e.clawhubPackage,
clawhubFamily: e.clawhubFamily,
...e.clawhubChannel ? { clawhubChannel: e.clawhubChannel } : {},
...e.clawhubTrustDisposition ? { clawhubTrustDisposition: e.clawhubTrustDisposition } : {},
...e.clawhubTrustScanStatus ? { clawhubTrustScanStatus: e.clawhubTrustScanStatus } : {},
...e.clawhubTrustModerationState ? { clawhubTrustModerationState: e.clawhubTrustModerationState } : {},
...e.clawhubTrustReasons ? { clawhubTrustReasons: e.clawhubTrustReasons } : {},
...e.clawhubTrustPending !== void 0 ? { clawhubTrustPending: e.clawhubTrustPending } : {},
...e.clawhubTrustStale !== void 0 ? { clawhubTrustStale: e.clawhubTrustStale } : {},
...e.clawhubTrustCheckedAt ? { clawhubTrustCheckedAt: e.clawhubTrustCheckedAt } : {},
...e.clawhubTrustAcknowledgedAt ? { clawhubTrustAcknowledgedAt: e.clawhubTrustAcknowledgedAt } : {},
...e.version ? { version: e.version } : {},
...e.integrity ? { integrity: e.integrity } : {},
...e.resolvedAt ? { resolvedAt: e.resolvedAt } : {},
...e.installedAt ? { installedAt: e.installedAt } : {},
...e.artifactKind ? { artifactKind: e.artifactKind } : {},
...e.artifactFormat ? { artifactFormat: e.artifactFormat } : {},
...e.npmIntegrity ? { npmIntegrity: e.npmIntegrity } : {},
...e.npmShasum ? { npmShasum: e.npmShasum } : {},
...e.npmTarballName ? { npmTarballName: e.npmTarballName } : {},
...e.clawpackSha256 ? { clawpackSha256: e.clawpackSha256 } : {},
...e.clawpackSpecVersion !== void 0 ? { clawpackSpecVersion: e.clawpackSpecVersion } : {},
...e.clawpackManifestSha256 ? { clawpackManifestSha256: e.clawpackManifestSha256 } : {},
...e.clawpackSize !== void 0 ? { clawpackSize: e.clawpackSize } : {}
};
}
//#endregion
export { normalizeClawHubClawPackInstallFields as n, buildClawHubPluginInstallRecordFields as t };