@erdoai/cli 0.55.3 → 0.56.0
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/dist/index.js +29 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -880,6 +880,11 @@ var ErdoClient = class {
|
|
|
880
880
|
setKnowledgeVisibility(id, visibility) {
|
|
881
881
|
return this.request("PATCH", `/v1/knowledge/${id}/visibility`, { visibility });
|
|
882
882
|
}
|
|
883
|
+
// asset_id is what a page's `assetId` field takes — attaching an image here
|
|
884
|
+
// is how it becomes something a published page can render.
|
|
885
|
+
attachKnowledgeAsset(objectID, input) {
|
|
886
|
+
return this.request("POST", `/v1/knowledge/${encodeURIComponent(objectID)}/attachments`, input);
|
|
887
|
+
}
|
|
883
888
|
// --- automations (heartbeats) ---
|
|
884
889
|
listHeartbeats() {
|
|
885
890
|
return this.request("GET", "/v1/heartbeats");
|
|
@@ -4031,6 +4036,30 @@ knowledgeCmd.command("visibility <id> <visibility>").description(
|
|
|
4031
4036
|
fail(e);
|
|
4032
4037
|
}
|
|
4033
4038
|
});
|
|
4039
|
+
knowledgeCmd.command("attach <objectId> <file>").description(
|
|
4040
|
+
"Attach an image or other small binary to a knowledge object as an org-hosted asset, and print its asset id \u2014 the value a page's assetId field takes. Pass a local path, or --url to have the service download it (the only path for video)."
|
|
4041
|
+
).option("--url <sourceUrl>", "download from this URL instead of reading a local file").option(
|
|
4042
|
+
"-d, --description <text>",
|
|
4043
|
+
"caption for the asset; for an image this is the only text search can match, so describe what is in the picture"
|
|
4044
|
+
).option("--media-type <mime>", "MIME type hint, e.g. image/jpeg; detected from the filename otherwise").action(
|
|
4045
|
+
async (objectId, file, opts) => {
|
|
4046
|
+
try {
|
|
4047
|
+
const body = opts.url ? { filename: basename(file), source_url: opts.url } : {
|
|
4048
|
+
filename: basename(file),
|
|
4049
|
+
content_base64: readFileSync3(file).toString("base64")
|
|
4050
|
+
};
|
|
4051
|
+
print(
|
|
4052
|
+
await new ErdoClient().attachKnowledgeAsset(objectId, {
|
|
4053
|
+
...body,
|
|
4054
|
+
description: opts.description,
|
|
4055
|
+
media_type: opts.mediaType
|
|
4056
|
+
})
|
|
4057
|
+
);
|
|
4058
|
+
} catch (e) {
|
|
4059
|
+
fail(e);
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
);
|
|
4034
4063
|
var autoCmd = program.command("automations").description("Scheduled automations (heartbeats)");
|
|
4035
4064
|
autoCmd.command("list").description("List automations").action(async () => {
|
|
4036
4065
|
try {
|