@seed-hypermedia/cli 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +27 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -165524,6 +165524,16 @@ async function resolveFileLinks(nodes) {
165524
165524
  }
165525
165525
 
165526
165526
  // src/commands/document.ts
165527
+ async function resolveCapability(client, targetAccount, signerAccount) {
165528
+ if (targetAccount === signerAccount)
165529
+ return;
165530
+ const targetId = unpackHmId3(`hm://${targetAccount}`);
165531
+ if (!targetId)
165532
+ return;
165533
+ const caps = await client.request("ListCapabilities", { targetId });
165534
+ const match = caps.capabilities.find((c) => c.delegate === signerAccount && (c.role === "WRITER" || c.role === "AGENT"));
165535
+ return match?.id;
165536
+ }
165527
165537
  async function readStdinBinary() {
165528
165538
  const chunks = [];
165529
165539
  for await (const chunk of process.stdin) {
@@ -165698,7 +165708,7 @@ function registerDocumentCommands(program2) {
165698
165708
  process.exit(1);
165699
165709
  }
165700
165710
  });
165701
- doc.command("create").description("Create a new document from markdown, JSON blocks, or PDF").option("-f, --file <path>", "Input file (format detected by extension: .md, .json, .pdf)").option("-p, --path <path>", 'Document path (e.g. "my-document")').option("--name <value>", "Document title (overrides frontmatter)").option("--summary <value>", "Document summary").option("--display-author <value>", 'Display author name (e.g. "Jane Doe")').option("--display-publish-time <value>", "Display publish time (YYYY-MM-DD)").option("--icon <value>", "Document icon (ipfs:// or file:// URL)").option("--cover <value>", "Cover image (ipfs:// or file:// URL)").option("--site-url <value>", "Site URL").option("--layout <value>", 'Document layout (e.g. "Seed/Experimental/Newspaper")').option("--show-outline", "Show document outline").option("--no-show-outline", "Hide document outline").option("--show-activity", "Show document activity").option("--no-show-activity", "Hide document activity").option("--content-width <value>", "Content width (S, M, L)").option("--seed-experimental-logo <value>", "Experimental logo (ipfs:// or file:// URL)").option("--seed-experimental-home-order <value>", "Home ordering (UpdatedFirst, CreatedFirst)").option("--import-categories <value>", "Import categories (comma-separated)").option("--import-tags <value>", "Import tags (comma-separated)").option("--grobid-url <url>", "GROBID server URL for PDF extraction").option("--dry-run", "Preview extracted content without publishing").option("--force", "Overwrite existing document at the same path (creates new lineage)").option("-k, --key <name>", "Signing key name or account ID").action(async (options2, cmd) => {
165711
+ doc.command("create").description("Create a new document from markdown, JSON blocks, or PDF").option("-f, --file <path>", "Input file (format detected by extension: .md, .json, .pdf)").option("-p, --path <path>", 'Document path (e.g. "my-document")').option("--name <value>", "Document title (overrides frontmatter)").option("--summary <value>", "Document summary").option("--display-author <value>", 'Display author name (e.g. "Jane Doe")').option("--display-publish-time <value>", "Display publish time (YYYY-MM-DD)").option("--icon <value>", "Document icon (ipfs:// or file:// URL)").option("--cover <value>", "Cover image (ipfs:// or file:// URL)").option("--site-url <value>", "Site URL").option("--layout <value>", 'Document layout (e.g. "Seed/Experimental/Newspaper")').option("--show-outline", "Show document outline").option("--no-show-outline", "Hide document outline").option("--show-activity", "Show document activity").option("--no-show-activity", "Hide document activity").option("--content-width <value>", "Content width (S, M, L)").option("--seed-experimental-logo <value>", "Experimental logo (ipfs:// or file:// URL)").option("--seed-experimental-home-order <value>", "Home ordering (UpdatedFirst, CreatedFirst)").option("--import-categories <value>", "Import categories (comma-separated)").option("--import-tags <value>", "Import tags (comma-separated)").option("--grobid-url <url>", "GROBID server URL for PDF extraction").option("--dry-run", "Preview extracted content without publishing").option("--force", "Overwrite existing document at the same path (creates new lineage)").option("-k, --key <name>", "Signing key name or account ID").option("-a, --account <uid>", "Target space/account UID (publish under a different account using a capability)").action(async (options2, cmd) => {
165702
165712
  const globalOpts = cmd.optsWithGlobals();
165703
165713
  const dev = !!globalOpts.dev;
165704
165714
  try {
@@ -165730,7 +165740,14 @@ function registerDocumentCommands(program2) {
165730
165740
  }
165731
165741
  const client = getClient(globalOpts);
165732
165742
  const key = resolveKey(options2.key, dev);
165733
- const account = key.accountId;
165743
+ const account = options2.account || key.accountId;
165744
+ let capability;
165745
+ if (options2.account && options2.account !== key.accountId) {
165746
+ capability = await resolveCapability(client, options2.account, key.accountId);
165747
+ if (!capability) {
165748
+ throw new Error(`No WRITER or AGENT capability found for key ${key.accountId} on account ${options2.account}. ` + `Use "account capabilities hm://${options2.account}" to check available capabilities.`);
165749
+ }
165750
+ }
165734
165751
  const { metadata: resolvedMeta, blobs: metaBlobs } = await resolveMetadataFileLinks(metadata);
165735
165752
  const rawPath = options2.path || slugify2(resolvedMeta.name || "Untitled");
165736
165753
  const path = rawPath.startsWith("/") ? rawPath : `/${rawPath}`;
@@ -165768,7 +165785,8 @@ function registerDocumentCommands(program2) {
165768
165785
  path,
165769
165786
  genesis: genesisBlock.cid.toString(),
165770
165787
  version: changeBlock.cid.toString(),
165771
- generation
165788
+ generation,
165789
+ capability
165772
165790
  }, signer);
165773
165791
  await client.publish({
165774
165792
  blobs: [
@@ -165856,6 +165874,7 @@ function registerDocumentCommands(program2) {
165856
165874
  const depCids = state.heads.map((h2) => CID.parse(h2));
165857
165875
  const newDepth = state.headDepth + 1;
165858
165876
  const signer = createSignerFromKey(key);
165877
+ const capability = await resolveCapability(client, docAccount, key.accountId);
165859
165878
  const { unsignedBytes, ts } = createChangeOps({ ops, genesisCid, deps: depCids, depth: newDepth });
165860
165879
  const changeBlock = await createChange(unsignedBytes, signer);
165861
165880
  const generation = Number(ts);
@@ -165864,7 +165883,8 @@ function registerDocumentCommands(program2) {
165864
165883
  path: docPath,
165865
165884
  genesis: state.genesis,
165866
165885
  version: changeBlock.cid.toString(),
165867
- generation
165886
+ generation,
165887
+ capability
165868
165888
  }, signer);
165869
165889
  await client.publish({
165870
165890
  blobs: [
@@ -165898,11 +165918,13 @@ function registerDocumentCommands(program2) {
165898
165918
  }
165899
165919
  const doc2 = resource.document;
165900
165920
  const generation = doc2.generationInfo ? Number(doc2.generationInfo.generation) : 0;
165921
+ const capability = await resolveCapability(client, unpacked.uid, key.accountId);
165901
165922
  const refInput = await createTombstoneRef({
165902
165923
  space: unpacked.uid,
165903
165924
  path: hmIdPathToEntityQueryPath3(unpacked.path),
165904
165925
  genesis: doc2.genesis,
165905
- generation
165926
+ generation,
165927
+ capability
165906
165928
  }, signer);
165907
165929
  await client.publish(refInput);
165908
165930
  if (!globalOpts.quiet)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-hypermedia/cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/seed-hypermedia/seed.git",